long v_nexa_ist_filter;
#define v_nexa_norm 60
#define v_nexa_min (25.5*(1024/v_nexa_norm))
The value calculate by the compiler is correct but if I make a compare with a long value like this:
Code:
if (v_nexa_ist_filter < v_nexa_min){
v_nexa_min_error=true;
}
I get and bad compare.
If I write
Code:
#define v_nexa_min 435
then all is correct.
Can anybody help me?
Ttelmah Guest
Re: problem with define
Posted: Wed Mar 10, 2004 11:17 am
Slammy wrote:
[i]can I make this define in a header file
Code:
long v_nexa_ist_filter;
#define v_nexa_norm 60
#define v_nexa_min (25.5*(1024/v_nexa_norm))
The value calculate by the compiler is correct but if I make a compare with a long value like this:
Code:
if (v_nexa_ist_filter < v_nexa_min){
v_nexa_min_error=true;
}
I get and bad compare.
If I write
Code:
#define v_nexa_min 435
then all is correct.
Can anybody help me?
Are you sure that the value being assigned is right. I'd be very suprised if it was!. You are asking the code to compare a float with a 16bit integer, and the compiler often has problems with this type of conversion.
If you code as:
#define v_nexa_min 435.0
which is what you are generating, you will get the same error.
To fix this, force the numbers to the same type. So:
#define v_nexa_min (long)(25.5*(1024/v_nexa_norm))
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum