What's wrong with my conditional that causes it to always evaluates to false (execute the else block)?
In main, t is declared as realtype, and ZERO is defined using a macro RCONST:
Code:
#define ZERO RCONST(0.0)
realtype reltol, abstol, t, tout;
realtype and RCONST are declared in a package. realtype is either float, double, or long double. In the current installation, realtype is a long double.
RCONST is to be used to for all floating point constants so that they are declared the same way as realtype:
Code:
#if defined(SUNDIALS_SINGLE_PRECISION)
...
#elif defined(SUNDIALS_DOUBLE_PRECISION)
...
#elif defined(SUNDIALS_EXTENDED_PRECISION)
typedef long double realtype;
# define RCONST(x) x##L
#endif
t's value is zero (I confirmed that in gdb). I've tried several forms of the conditional, but all have failed (actually, they all work correctly, but they all evaluate to false):
Code:
if (t == ZERO) ...
if (t == 0) ...
if (t == 0.0) ...
if (t == 0.0L) ...
All of those executed the else statement, even when t is zero. Pretty obviously the second one will not work right.
Code:
printf("%4.0Lf\t", t);
if (t == 0.0L) {
printf("THEN");
} else {
printf("ELSE");
}
Output:
0 ELSE ...
100 ELSE ...
200 ELSE ...
...
So, what's wrong with my conditional that causes it to always evaluates to false (execute the else block), even when t is zero? How do I make this work right?
Thanks.