P
Peter Ammon
I'm fuzzy on exactly what I can depend on when doing floating point
comparisons. I know that calculated values can differ, e.g. I'm not
guaranteed that 1. + 2. == 3.
What about comparisons with literals?
float f=3.;
int v = f==3.;
is v guaranteed to be one? What about situations involving conversions
between floats and doubles?
int v = 3.f == 3.;
How about for values calculated from strings?
int v = strtod("3.0", NULL)==3.;
Any other situations I should know about?
Thanks for any advice,
-Peter
comparisons. I know that calculated values can differ, e.g. I'm not
guaranteed that 1. + 2. == 3.
What about comparisons with literals?
float f=3.;
int v = f==3.;
is v guaranteed to be one? What about situations involving conversions
between floats and doubles?
int v = 3.f == 3.;
How about for values calculated from strings?
int v = strtod("3.0", NULL)==3.;
Any other situations I should know about?
Thanks for any advice,
-Peter