CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

problem with define

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Slammy



Joined: 10 Mar 2004
Posts: 2

View user's profile Send private message

problem with define
PostPosted: Wed Mar 10, 2004 7:42 am     Reply with quote

[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?
Ttelmah
Guest







Re: problem with define
PostPosted: Wed Mar 10, 2004 11:17 am     Reply with quote

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))

will make it work.

Best Wishes
Slammy



Joined: 10 Mar 2004
Posts: 2

View user's profile Send private message

PostPosted: Thu Mar 11, 2004 1:48 am     Reply with quote

Thanks a lot. Now it works.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group