php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19398 mathmatical errors, especially after string conversions
Submitted: 2002-09-13 20:03 UTC Modified: 2002-09-17 04:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: jeffb at umci dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.2 OS: Redhat 7.3
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jeffb at umci dot com
New email:
PHP Version: OS:

 

 [2002-09-13 20:03 UTC] jeffb at umci dot com
The script below produces a lot of output on two of 
our systems. One a 6 cpu ppro, the other a single
cpu duron 950. Both boxes run redhat 7.3. One runs the
php that came with redhat 7.3, the 6 cpu box runs php
4.2.2 that we compiled ourselves to add more options.

For sample output of this script, with a phpinfo() call
appended to it, go to:

http://www.umci.com/testcode.phtml


<?
$start=0.01;
while ($start <= 10) {
// Removing the quotes from test's assignment will eliminate the 
// errors unless you uncomment the ++/-- down a fiew lines.
$test="$start";
$test2=$start;

/////////////////////////////////////////////////////////////////
// Uncommenting these two lines accentuates the problem a bit...
/////////////////////////////////////////////////////////////////
//$test++;
//$test--;

if ($test!=$test2)
echo "Comparison Result: \"$test\" != \"$test2\" ----- Shouldn't this be true?<br>";
$start = $start + 0.01;
} 

?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-17 04:43 UTC] hholzgra@php.net
Never compare floats for equalness!

Thats like comparing two pieces of rope
for exactly equal length -> you won't 
ever find an equal pair

see for example the note on http://www.php.net/language.types.float
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 16:01:27 2024 UTC