diff options
author | Hartmut Holzgraefe <hholzgra@php.net> | 2000-03-01 19:36:37 +0000 |
---|---|---|
committer | Hartmut Holzgraefe <hholzgra@php.net> | 2000-03-01 19:36:37 +0000 |
commit | 33cb181af2051ba3aa50e1cabe0575b32672ce44 (patch) | |
tree | 5ebe7583e739a28bc1683d33be8911b52bef70ff /ext/standard/math.c | |
parent | 4dd71d4cfe1cd7d38034b5ebf6bbb0f6b59d79d1 (diff) | |
download | php-git-33cb181af2051ba3aa50e1cabe0575b32672ce44.tar.gz |
round(-0.1) will now return 0 instead of -0
Diffstat (limited to 'ext/standard/math.c')
-rw-r--r-- | ext/standard/math.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/standard/math.c b/ext/standard/math.c index 73c7f6dc58..0cc81dda61 100644 --- a/ext/standard/math.c +++ b/ext/standard/math.c @@ -101,6 +101,7 @@ PHP_FUNCTION(floor) { /* }}} */ /* {{{ proto int round(double number) + Returns the rounded value of the number */ #ifndef HAVE_RINT @@ -128,7 +129,10 @@ PHP_FUNCTION(round) convert_scalar_to_number_ex(value); if ((*value)->type == IS_DOUBLE) { - RETURN_DOUBLE(rint((*value)->value.dval)); + double d; + d=rint((*value)->value.dval); + if(d==0.0) d=0.0; /* workaround for rint() returning -0 instead of 0 */ + RETURN_DOUBLE(d); } else if ((*value)->type == IS_LONG) { RETURN_DOUBLE((double)(*value)->value.lval); } |