### _srotl - _srotr -- Rotate Bits of Unsigned Short Value

Format

>     #include <stdlib.h>   /* also in <builtin.h> */

>     unsigned short _srotl(unsigned short value, int shift);
>     unsigned short _srotr(unsigned short value, int shift);

Language Level: Extension
The _srotl and _srotr functions rotate the unsigned short integer value by shift bits. The _srotl function rotates to the left, and _srotr to the right.

Note: Both _srotl and _srotr 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 function's backing code, and these functions have none.)

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

Example
This example uses _srotl and _srotr with different shift values to rotate the character value:

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

    int main(void)
    {
       unsigned short val = 0X0123;

       printf("The value of 0x%4.4x rotated 4 bits to the left is 0x%4.4x\n", val,
          _srotl(val, 4));
       printf("The value of 0x%4.4x rotated 8 bits to the right is 0x%4.4x\n",
          val, _srotr(val, 8));
       return 0;

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

          The value of 0x0123 rotated 4 bits to the left is 0x1230
          The value of 0x0123 rotated 8 bits to the right is 0x2301
       ****************************************************************************/
    }

_crotl - _crotr -- Rotate Bits of Character Value
_lrotl - _lrotr -- Rotate Bits of Unsigned Long Value
_rotl - _rotr -- Rotate Bits of Unsigned Integer
<stdlib.h>
<builtin.h>