summaryrefslogtreecommitdiff
path: root/Zend/zend_strtod.c
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2008-12-03 20:30:45 +0000
committerSVN Migration <svn@php.net>2008-12-03 20:30:45 +0000
commit2876046398950e59c3b3c460e67e6fec7ff2ba3c (patch)
tree33b2b8b4b859960a6446ad19d0ada1c55f9cfcda /Zend/zend_strtod.c
parent3fb86b0b9e79e6a3312b694f30ee627e2e1b325c (diff)
downloadphp-git-php-5.3.0alpha2.tar.gz
This commit was manufactured by cvs2svn to create tag 'php_5_3_0alpha2'.php-5.3.0alpha2
Diffstat (limited to 'Zend/zend_strtod.c')
-rw-r--r--Zend/zend_strtod.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/Zend/zend_strtod.c b/Zend/zend_strtod.c
index 4a3e976d25..a65b738b53 100644
--- a/Zend/zend_strtod.c
+++ b/Zend/zend_strtod.c
@@ -93,7 +93,6 @@
#include <zend_operators.h>
#include <zend_strtod.h>
-#include <zend_float.h>
#ifdef ZTS
#include <TSRM.h>
@@ -1721,7 +1720,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;
}
@@ -2033,7 +2039,6 @@ ret1:
ZEND_API double zend_strtod (CONST char *s00, char **se)
{
- ZEND_FLOAT_DECLARE
int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
CONST char *s, *s0, *s1;
@@ -2046,8 +2051,6 @@ ZEND_API double zend_strtod (CONST char *s00, char **se)
CONST char decimal_point = '.';
- ZEND_FLOAT_ENSURE();
-
sign = nz0 = nz = 0;
value(rv) = 0.;
@@ -2578,7 +2581,7 @@ ret:
}
_THREAD_PRIVATE_MUTEX_UNLOCK(pow5mult_mutex);
- ZEND_FLOAT_RETURN(result);
+ return result;
}
ZEND_API double zend_hex_strtod(const char *str, char **endptr)