Well that's absolutely not true.
== works for
floating-point numbers just fine.
Note that both the rvalue and the lvalue must be of the same type, float not double.
The other way is to implement the
fabs function, since gE's math library doesn't provide it for some reason.
- Code: Select all
unsigned double fabs(signed double n) { return((n >= 0.0) ? (n) : (0.0 - n)); }
And a function to take advantage of it, something like:
- Code: Select all
int fequal (float a, float b, float epsilon) { return fabs(a-b) < epsilon; }
will return 1 if a equals b with epsilon of 1/1048576
____________________________________________________________________________________________________________________________________________
Ehh,
round just rounds it up as if you take the integer part with
modf or type-casting to an integral type
and it looses the point of being a floating-point number..
____________________________________________________________________________________________________________________________________________
The other way is to compare it with a number with 0s equal to the number of signs your float consists of.
And this is a lot like Koala's approach, however his won't work with doubles and thus with higher precision.