#41714 [Opn->Bgs]: Problem with intval()
| From: | johannes@php.net | Date: | Sun, 17 Jun 2007 09:34:19 +0000 |
| Subject: | #41714 [Opn->Bgs]: Problem with intval() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-113864@lists.php.net to get a copy of this message | ||
ID: 41714
Updated by: johannes@php.net
Reported By: bartlomiejbak at gmail dot com
-Status: Open
+Status: Bogus
Bug Type: *Math Functions
Operating System: ubuntu
PHP Version: 5.2.3
New Comment:
Floating point values have a limited precision. Hence a value might
not have the same string representation after any processing. That also
includes writing a floating point value in your script and directly
printing it without any mathematical operations.
If you would like to know more about "floats" and what IEEE
754 is read this:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
Thank you for your interest in PHP.
.
Previous Comments:
------------------------------------------------------------------------
[2007-06-16 21:18:01] bartlomiejbak at gmail dot com
Description:
------------
Hi. I've got a little bit problem
this code should show me result of equation 20x + 27y = 1
for ($y = 0; $y < 1000; $y++)
{
$x = (1/20) - (27/20) * $y;
if ($x == intval($x)) $out .= "x: $x,y: $y\n";
}
I need only int values of X and Y but intval() sometimes return wrong
value. Result should be (-4,3),(-31,23),(-58,43) etc. but php is
starting showing from (-31,23)...
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41714&edit=1