RE: Strange math results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is not always possible to precisely represent decimal values as a
float type in binary. In these cases, the value that you have is either
slightly bigger or slightly smaller than the actual. 

In your specific problem, you have two values that are not equal, but
very similar. Therefore you get a small negative value when subtracting
them.

You just have to keep this fact in mind whenever you want to do high-
precision computing.



On Tue, 2006-03-28 at 15:30 -0600, Jay Blanchard wrote:
> [snip]
> I've got a strange problem here.
> 
> I'm subtacting one variable from another, both of type "double" and if
> they are the same, instead of getting a result of 0, I get something
> like -9.99200722163E-016
> 
> Is this a bug or am I doing something wrong here?
> [/snip]
> 
> From all of the information that you sent in your post I'd say that
> you're doing something wrong here. 
> 

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux