http://www.velocityreviews.com/forums/(E-Mail Removed) writes:

> I want to fill in an unsigned int variable with n 1s. Example: n = 4

> --> var = 00...001111 in binary.
If n is less than the number of value bits in an unsigned int:

x = (1u << n) - 1;

If n might be (greater than or) equal to the number of value

bits:

x = n < NUM_VALUE_BITS ? (1u << n) - 1 : UINT_MAX;

where NUM_VALUE_BITS is the width of unsigned int, which is

typically CHAR_BIT * sizeof (unsigned int) but might be smaller.

--

"If I've told you once, I've told you LLONG_MAX times not to

exaggerate."

--Jack Klein