I referred to the accuracy of result *acceptable to one*, if there are cases
that 0.2 and 0.29 may occur, and u still want to go with a 1.0e-5
value as a zero equality check, its your code, screw it up. If one knows
that such corner cases might come and he decides to discard them, fine, els
@Avi: Whether this is a safe implementation depends in part on whether
you want to say that 0.2 == 0.29 because they differ by less
than 1.0e-5, even though they differ by 45%. Applying your
philosophical boilerplate, you have to use some intelligence even in
this type of thing.
Dave
On J
Thanx for the precise information.
I was coming from a perspective of safe implementation, when dealing with
variables, you might not always know whether the values to be compared will
fall under the exact floating point representation, so the safe way to go
might always be to use the < 1.0e-5 met
I don't think your example with == would ever fail. According to the
IEEE floating point standard, integers within the dynamic range of the
number type must be represented exactly and must compare as equal.
Furthermore, the four basic operations on integers within the dynamic
range of the floating
Just to mention, floating point numbers r always compared *for equality*
like
double d1 = 90.0;
double d2 = 90.0;
assert(d1 == d2); // might fail, and Wrong way to do !!
assert(d1 - d2 < 1e-5); // given u assume precision of 1e-5, is the correct
and recommended way.
Programmers should realize
Numbers without fractional parts are represented exactly (in a range
supported by double).
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send
not always. well , i got some problem using that approachwhen the output is
coming out of some library function , this doesn't qualify always i wlll
find an example by tomorrow.
On Thu, Jan 6, 2011 at 11:48 PM, juver++ wrote:
> On my computer k == p.
>
> --
> You received this message because yo
On my computer k == p.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options, v