On Monday 01 November 2004 04:52, Brian T. Allen wrote:

> OK, I'm totally stumped by this.   This should be the simplest math
> imaginable (addition and subtraction), but PHP is coming up with the
> wrong answer!
>
> I've checked on 3 different machines (all linux) running both PHP 4 and
> PHP 5.
>
> Here is the code to duplicate the problem:

[snip]

> Now I'm the first to admit that 0.000000000000284217094304 and 0 are
> really very close, but when you are testing a variable to see if it
> equals 0, it is the difference between true and false.
>
> This seems very, very basic to me, but I can't find the flaw in my code.
>
> Is this legitimately bad math on the part of PHP?

Most computer languages handling floating point calculations just as poorly. 
If accuracy is important use the BCMath functions.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
BOFH Excuse #332:

suboptimal routing experience
*/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to