Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccff
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.

...