Bug #54458 [Opn->Bgs]: Comparison with intval()
| From: | cataphract@php.net | Date: | Sun, 03 Apr 2011 18:49:18 +0000 |
| Subject: | Bug #54458 [Opn->Bgs]: Comparison with intval() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-159937@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54458&edit=1
ID: 54458
Updated by: cataphract@php.net
Reported by: cs dot luizeduardo at hotmail dot com
Summary: Comparison with intval()
-Status: Open
+Status: Bogus
Type: Bug
Package: Variables related
Operating System: Windows
PHP Version: 5.3SVN-2011-04-03 (SVN)
Block user comment: N
Private report: N
New Comment:
In[1]:= SetAccuracy[(1.1*100.), Infinity] - 110 // N[#, 20] &
Out[1]= 1.4210854715202003717*10^-14
In[2]:= SetAccuracy[110., Infinity] - 110 // N[#, 20] &
Out[2]= 0
110 is exactly representable in an IEEE 754 double precision number; 1.1
is not. When 1.1 is multiplied by 100, the error in the representation
of 1.1 is propagated and we don't end up with the exact 110. In PHP:
echo sprintf("%.20f %.20f\n", 110., 1.1 * 100);
110.00000000000000000000 110.00000000000001421085
Closing as bogus.
Previous Comments:
------------------------------------------------------------------------
[2011-04-03 17:31:45] cs dot luizeduardo at hotmail dot com
Description:
------------
comparisons with intval() function with real values between 1 and 2
(like 1.2 1.3
etc).
Every return any fail;
Test script:
---------------
$numero = "1.1";
if (intval($numero * 100) == $numero * 100)
{
echo intval($numero * 100) . ":" . $numero * 100 . "<br/>";
echo "Number OK!";
} else {
echo intval($numero * 100) . ":" . $numero * 100 . "<br/>"; //Return
110:110 (same) but the comparison has fail
echo "The number shoud contains 2 decimal places";
}
Expected result:
----------------
110:110
Number OK!
OBS: With the variable with the 2.1 for example, the return result are
the
expected.
Actual result:
--------------
110:110
The number shoud contains 2 decimal places
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54458&edit=1