Edit report at http://bugs.php.net/bug.php?id=53222&edit=1

 ID:                 53222
 Updated by:         [email protected]
 Reported by:        viliam dot kubis at gmail dot com
 Summary:            "less than" operator returning true even if numbers
                     are equal
-Status:             Closed
+Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   fedora 13
 PHP Version:        5.3.3
 Block user comment: N



Previous Comments:
------------------------------------------------------------------------
[2010-11-02 02:24:59] viliam dot kubis at gmail dot com

I'm sorry, my mistake. Did not read carefully about floats in the
manual. Sure you can't safely compare them for equality, but that also
means you can't safely compare them with "<" and ">" operators. The code
works when using BCMath. Thanks.

------------------------------------------------------------------------
[2010-11-02 02:06:04] viliam dot kubis at gmail dot com

Description:
------------
I am using the following PHP version:



PHP 5.3.3 (cli) (built: Jul 22 2010 15:57:00) 



Info: re-typing everything to (float), (double) or "no type specified"
does not fix the problem.

Test script:
---------------
<? 

$min=(float)44;

$max=(float)54545;



$step=(float)($max-$min)/10;



if($step && $step>0)

{

        $i=$min;

        while($i<$max)

        {

                echo($i." &lt; $max ");

                var_dump($i,$max,$step);

                echo("<br />");

                $i+=$step;

        }

}

if($i>$max) echo("WHAT?");  ?> 

Expected result:
----------------
44 < 54545 float(44) float(54545) float(5450.1) 

5494.1 < 54545 float(5494.1) float(54545) float(5450.1) 

10944.2 < 54545 float(10944.2) float(54545) float(5450.1) 

16394.3 < 54545 float(16394.3) float(54545) float(5450.1) 

21844.4 < 54545 float(21844.4) float(54545) float(5450.1) 

27294.5 < 54545 float(27294.5) float(54545) float(5450.1) 

32744.6 < 54545 float(32744.6) float(54545) float(5450.1) 

38194.7 < 54545 float(38194.7) float(54545) float(5450.1) 

43644.8 < 54545 float(43644.8) float(54545) float(5450.1) 

49094.9 < 54545 float(49094.9) float(54545) float(5450.1) 



Actual result:
--------------
44 < 54545 float(44) float(54545) float(5450.1) 

5494.1 < 54545 float(5494.1) float(54545) float(5450.1) 

10944.2 < 54545 float(10944.2) float(54545) float(5450.1) 

16394.3 < 54545 float(16394.3) float(54545) float(5450.1) 

21844.4 < 54545 float(21844.4) float(54545) float(5450.1) 

27294.5 < 54545 float(27294.5) float(54545) float(5450.1) 

32744.6 < 54545 float(32744.6) float(54545) float(5450.1) 

38194.7 < 54545 float(38194.7) float(54545) float(5450.1) 

43644.8 < 54545 float(43644.8) float(54545) float(5450.1) 

49094.9 < 54545 float(49094.9) float(54545) float(5450.1) 

54545 < 54545 float(54545) float(54545) float(5450.1) 

WHAT?


------------------------------------------------------------------------



-- 
Edit this bug report at http://bugs.php.net/bug.php?id=53222&edit=1

Reply via email to