Forum Discussion
Altera_Forum
Honored Contributor
14 years agoYou'll also find that the x86 cpu ignores all the high bits of a shift count.
Oh definitions like:static const uint32_t one = 1u;are just completely pointless. It is much clearer if you just write: uint32_t makeMask(uint32_t count)
{
return count >= 31 ? 0xffffffffu : (1u << count) - 1;
} All the temporary variables just make it harder to read. (That isn't quite your function, but is closer to the one you wanted!)