Bug #1259: Double in a string comparision bug after converting with strval and intval
| From: | mlemos at acm dot org | Date: | Tue, 23 Mar 1999 06:03:31 +0000 |
| Subject: | Bug #1259: Double in a string comparision bug after converting with strval and intval | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-4734@lists.php.net to get a copy of this message | ||
From: mlemos@acm.org
Operating system: Any
PHP version: 3.0.7
PHP Bug Type: Misbehaving function
Bug description: Double in a string comparision bug after converting with strval and intval
The following script should demonstrate that if you have a floating point
number in a string and then convert it with intval and strval, PHP says
they are the same where they shouldn't be.
<?
$value="1.";
echo
"(\"$value\"==strval(intval(\"$value\")))=",$value==strval(intval($value)),"
intval(\"$value\")=",intval($value),"\n";
$value=".1";
echo
"(\"$value\"==strval(intval(\"$value\")))=",$value==strval(intval($value)),"
intval(\"$value\")=",intval($value),"\n";
$value="1.0";
echo
"(\"$value\"==strval(intval(\"$value\")))=",$value==strval(intval($value)),"
intval(\"$value\")=",intval($value),"\n";
$value="1";
echo
"(\"$value\"==strval(intval(\"$value\")))=",$value==strval(intval($value)),"
intval(\"$value\")=",intval($value),"\n";
?>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net