### _rotl - _rotr -- Rotate Bits of Unsigned Integer

Format

>     #include <stdlib.h>   /* also in <builtin.h> */
>     unsigned int _rotl(unsigned int value, int shift);
>     unsigned int _rotr(unsigned int value, int shift);

Language Level: Extension
These functions take a 4-byte integer value and rotate it by shift bits. _rotl rotates to the left, and _rotr to the right.

Note: Both _rotl and _rotr are built-in functions, which means they are implemented as inline instructions and have no backing code in the library. For this reason:

- You cannot take the address of these functions.
- You cannot parenthesize a call to either function. (Parentheses specify a call to the backing code for the function in the runtime library.)

Portability Consideration: Because the size of an int is only 2 bytes in 16-bit compilers, if you are migrating 16-bit programs, some parts of your programs may have to be rewritten if they use this function.

Return Value
Both functions return the rotated value. There is no error return.

Example
This example uses _rotr and _rotl with different shift values to rotate the integer value 0x01234567:

    #include <stdio.h>
    #include <stdlib.h>

    int main(void)
    {
       unsigned int val = 0X01234567;

       printf("The value of 0x%8.8lx rotated 4 bits to the left is 0x%8.8lx\n", val,
          _rotl(val, 4));
       printf("The value of 0x%8.8lx rotated 16 bits to the right is 0x%8.8lx\n",
          val, _rotr(val, 16));
       return 0;

       /****************************************************************************
          The output should be:

          The value of 0x01234567 rotated 4 bits to the left is 0x12345670
          The value of 0x01234567 rotated 16 bits to the right is 0x45670123
       ****************************************************************************/
    }

_crotl - _crotr -- Rotate Bits of Character Value
_lrotl - _lrotr -- Rotate Bits of Unsigned Long Value
_llrotl - _llrotr -- Rotate Bits of Unsigned Long Long Integer
_srotl - _srotr -- Rotate Bits of Unsigned Short Value
swab -- Swap Adjacent Bytes
<builtin.h>
<stdlib.h>