...
Code Block | ||
---|---|---|
| ||
unsigned int si1ui1, si2ui2, sresult; if ((si2ui2 >= sizeof(int)*CHAR_BIT) || (si1ui1 > (INT_MAX >> si2ui2)) ) { /* handle error condition */ } else { sresult = si1ui1 << si2ui2; } |
In C99, the CHAR_BIT
macro defines the number of bits for the smallest object that is not a bit-field (byte). Consequently, a byte contains CHAR_BIT
bits.
...