summaryrefslogtreecommitdiff
path: root/Zend/zend_strtod.c
diff options
context:
space:
mode:
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;
}