|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-11-18 14:13 UTC] uwe dot voelker at vline dot de
Description:
------------
Addition of some negative floats fails !
Reproduce code:
---------------
<?php
// PHP 5.05
// First example shows the bug
if ( (-56.33) != ((-14.13) + (-42.20)) ) {
print "<HR> First Example: Why is -56.33 not -56.33 ??? <HR>";
}
else
{
print "<HR> First Example: OK <HR>";
}
// Second example with modified values but same result is ok
if ( (-56.33) != ((-14.12) + (-42.21)) ) {
print "<HR> Second Example: Why is -56.33 not -56.33 ??? <HR>";
}
else
{
print "<HR> Second Example: OK <HR>";
}
?>
Expected result:
----------------
First example: true, but must be false.
Second example: false, it is OK.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 01 04:00:01 2025 UTC |
OK, after reading ten pages about float i take the ROUND function, it works now. if ( (-56.33) != Round((-14.13) + (-42.20),2) ) { print "<HR> First Example: Why is -56.33 not -56.33 ??? <HR>"; } else { print "<HR> First Example: OK <HR>"; }