kasiyil schreef:
Hi There,
> Hello,
>
> what is the disadvantage of using floating point numbers in boolean
> comparisons. For example,
>
> why using #define FALSE 0.0 will produce error instead of #define FALSE
> 0?
The
#define FALSE 0.0
will not produce an error, it's legal c(++).
It's better style to write:
const double FALSE = 0.0;
but they should work kinda alike.
There are a lot of disadvantages, allmost to many to start, but the
main one is that you are mixing types. Bools are used to express
boolean values, doubles are used to express numbers. The world is far
more simpler if everybody tries to do this!
And did you know that c++ had an build-in constant called 'false'? I'd
use that one if I was you.
Good luck,
colander
|