Hello,

this is how floating point numbers work.

3.55 as float is not 'exactly' 3.55, but it is stored in memory as an as
good as possible representation, something like 3.55000000001 perhaps.

If you simply compare this:
3.55000000000001 + 60.12000000000000001 != 63.66666666666669

so that's why the comparison fails.

Derick

On Tue, 4 Dec 2001, Matthew Hagerty wrote:

> Greetings,
>
> Explain to me why the first condition fails!
>
> <?php
>
>       $fFloat1 = 3.55 + 60.12;
>       $fFloat2 = 63.67;
>
>       if ( $fFloat1 == $fFloat2 )
>               print "Equal";
>       else
>               print "Not Equal";
>
>       settype($fFloat1, "string");
>       settype($fFloat1, "double");
>
>       if ( $fFloat1 == $fFloat2 )
>               print "Equal";
>       else
>               print "Not Equal";
>
> ?>
>
> Thanks,
> Matthew
>
>
>
> --
> PHP Development Mailing List <http://www.php.net/>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to