> -Original Message-
> From: Satyam [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, March 28, 2006 17:23
> To: [EMAIL PROTECTED]; Jay Blanchard
> Cc: Jeff; php-general@lists.php.net
> Subject: Re: [PHP] Strange math results
>
>
> Indeed, when doing floating point
Indeed, when doing floating point math, you cannot check the values for
equality, they will rarely be, you have to check whether the difference in
between them is less than the error you are willing to accept. Floating
point numbers are usually an approximation to the actual value and
interme
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
[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
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?
Thanks,
Jeff
--
PHP General Mailing List (htt
5 matches
Mail list logo