This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

which is better to use

Hi,

Which is better to use
#define TRUE 1
#define FALSE 0
if(a==TRUE)
{ }
if(a!=FASE)
{ }
whether both makes any difference in code size or speed?

Thanks,

Parents
  • Why not just:

    if (a) {
        ...
    }
    


    Remember that any non-zero value is evaluated as true. A comparison by "TRUE" and "FALSE" may be good for high-reliability software where you want to make sure that there are only one value that is true and one value that is false and that any other value gets caught and considered a problem with memory, memory overwrites, ... But for such systems, you wouldn't normally use 0 and 1 as false and true constants anyway.

    But for normal applications, a comparison with 1 is bothersome since 1 isn't a magic value the processor have easy access to. Zero is, since the processor have a special flag for zero/non-zero.

Reply
  • Why not just:

    if (a) {
        ...
    }
    


    Remember that any non-zero value is evaluated as true. A comparison by "TRUE" and "FALSE" may be good for high-reliability software where you want to make sure that there are only one value that is true and one value that is false and that any other value gets caught and considered a problem with memory, memory overwrites, ... But for such systems, you wouldn't normally use 0 and 1 as false and true constants anyway.

    But for normal applications, a comparison with 1 is bothersome since 1 isn't a magic value the processor have easy access to. Zero is, since the processor have a special flag for zero/non-zero.

Children
No data