Format
#include <stdlib.h> /* also in <builtin.h> */ unsigned long long _llrotl(unsigned long long value, int shift); unsigned long long _llrotr(unsigned long long value, int shift);
Language Level: Extension
These functions take a 8-byte unsigned (long long)
integer value and rotate it by shift
bits. _llrotl rotates to the left, and _llrotr to the right.
Note: Both _llrotl and _llrotr are built-in functions, which means they are implemented as inline instructions and have no backing code in the library. For this reason:
Return Value
Both functions return the rotated value. There
is no error return.
Example
This example uses _llrotr and _llrotl
with different shift values to rotate the integer value
0x01234567:
#include <stdio.h> #include <stdlib.h>
int main(void)
{
unsigned long long val = 0x0123456789abcdefull;
printf("The value of 0x%16.16llx rotated 4 bits to the left is 0x%16.16llx\n", val,
_llrotl(val, 4));
printf("The value of 0x%16.16llx rotated 16 bits to the right is 0x%16.16llx\n",
val, _llrotr(val, 16));
return 0;
/**************************************************************************************
The output should be:
The value of 0x0123456789abcdef rotated 4 bits to the left is 0x123456789abcdef0
The value of 0x0123456789abcdef rotated 16 bits to the right is 0xcdef0123456789ab
**************************************************************************************/
}
![]()
_crotl - _crotr -- Rotate
Bits of Character Value
_lrotl - _lrotr
-- Rotate Bits of Unsigned Long Value
_rotl - _rotr --
Rotate Bits of Unsigned Integer
_srotl - _srotr
-- Rotate Bits of Unsigned Short Value
swab -- Swap
Adjacent Bytes
<builtin.h>
<stdlib.h>