atof approximates the String, I need exact value of the string passed

P

peter koch

asterisc skrev:

[snip]
Indeed, very improbable, but not impossible. Anyway, i just wanted to
express that if you need to check if two floating numbers are equal,
then don't rely on the '==';

On the contrary. "==" is the only way to compare equality. Use your
EPSILON stuff to test for proximity, not for anything else.

[snip]

/Peter
 
P

Pete Becker

asterisc said:
Indeed, very improbable, but not impossible.

Sure. Cosmic rays, random hardware failures, etc. But when you use the
same expression to initialize values of the same type you get the same
value.

Anyway, i just wanted to
express that if you need to check if two floating numbers are equal,
then don't rely on the '==';

And that is simply wrong. == tells you whether two floating-point values
are equal. If what you really want to know is whether they're
approximately equal, that's up to you. But when you do that you bring in
a new set of complications that most people who recommend this approach
haven't taken the time to understand.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,444
Messages
2,571,709
Members
48,796
Latest member
Greg L.
Top