summaryrefslogtreecommitdiff
path: root/Zend/zend_strtod.c
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-04-19 09:30:49 +0000
committerAntony Dovgal <tony2001@php.net>2007-04-19 09:30:49 +0000
commit9ad2c80c62246ccf79a3eb044a67958dde0e281e (patch)
tree4a28b1f674e3629b29312a7670e638a5c3a6592d /Zend/zend_strtod.c
parent52a9667c3a5c9a1773c589ebfa70c62e863f6a8e (diff)
downloadphp-git-9ad2c80c62246ccf79a3eb044a67958dde0e281e.tar.gz
fix double-to-string conversion utils
Diffstat (limited to 'Zend/zend_strtod.c')
-rw-r--r--Zend/zend_strtod.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
index 798d94a384..94d1383aa2 100644
--- a/Zend/zend_strtod.c
+++ b/Zend/zend_strtod.c
@@ -1707,7 +1707,14 @@ ZEND_API char * zend_dtoa(double _d, int mode, int ndigits, int *decpt, int *sig
if (value(d) > 0.5 + value(eps))
goto bump_up;
else if (value(d) < 0.5 - value(eps)) {
- while(*--s == '0');
+ /* cut ALL traling zeros only if the number of chars is greater than precision
+ * otherwise cut only extra zeros
+ */
+ if (k < ndigits) {
+ while(*--s == '0' && (s - s0) > k);
+ } else {
+ while(*--s == '0');
+ }
s++;
goto ret1;
}