Edit report at http://bugs.php.net/bug.php?id=54842&edit=1

 ID:                 54842
 Updated by:         ras...@php.net
 Reported by:        php at maisqi dot com
 Summary:            ceil yields a negative zero
-Status:             Open
+Status:             Bogus
 Type:               Bug
 Package:            *Math Functions
 Operating System:   Windows XP32
 PHP Version:        5.3.6
 Block user comment: N
 Private report:     N

 New Comment:

This is not a bug. All floating point operations is done using IEEE-754
and both 

positive and negative 0 exists. You can read more about it here.



http://en.wikipedia.org/wiki/Signed_zero



You can add 0 to your result to make it never show -0 if you like.



eg. 0+ceil(...)


Previous Comments:
------------------------------------------------------------------------
[2011-05-18 17:24:03] php at maisqi dot com

Description:
------------
When doing some math with dates and "ceiling" the result, I got a
negative zero!

I don't understand how that can be, so I presume it's an error.

Test script:
---------------
<?php



$dt = mktime (0, 0, 0, 5, 18, 2011);

$base = mktime (16, 16, 0, 5, 18, 2011);



echo 'dt: ', date ('Y-m-d', $dt), '<br />';

echo 'base: ', date ('Y-m-d', $base), '<br />';



echo '<br />';

echo 'dt - base: <strong>', ceil (($dt - $base) / 86400), '</strong>';



?>

<br /><br />

It outputs "-0" on PHP 5.3.6, under Windows XP 32 bits

Expected result:
----------------
The bolded text should be "0" (zero)

Actual result:
--------------
The bolded text is "-0" (negative zero)


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=54842&edit=1

Reply via email to