...
A portable (and safer) way to set all the bits on in an integer constant of type unsigned long is to define a constant with a value of ~0a complement of 0 (defined to be the appropriate type).
| Code Block | ||
|---|---|---|
| ||
const unsigned long mask = ~0~0UL; unsigned long x; /* Initialize x */ x = (x ^ mask) + 1; |
...