compacting line of code

Posted by dlee313 on Stack Overflow See other posts from Stack Overflow or by dlee313
Published on 2010-06-10T18:28:51Z Indexed on 2010/06/10 18:32 UTC
Read the original article Hit count: 183

Filed under:

Assume I have the following:

unsigned int *start;
unsigned int total;

#define OFF_MASK (1 << 31)
#define ON_MASK (~(1 << 31))


if (!(*start & OFF_MASK) && ((*start & ON_MASK) >= total)))

How do I change the above if statement so that it makes just one comparison like this:

if (*start >= total)

© Stack Overflow or respective owner

Related posts about c