]> granicus.if.org Git - php/commitdiff
round(-0.1) will now return 0 instead of -0
authorHartmut Holzgraefe <hholzgra@php.net>
Wed, 1 Mar 2000 19:36:37 +0000 (19:36 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Wed, 1 Mar 2000 19:36:37 +0000 (19:36 +0000)
ext/standard/math.c

index 73c7f6dc58f3a773799bcb65cb894c6e7a1da7ca..0cc81dda613bbca54ffccc81a03ed905aba8e465 100644 (file)
@@ -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);
        }