title | ms.custom | ms.date | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | apiname | apilocation | apitype | f1_keywords | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
_lrotl, _lrotr | Microsoft Docs |
11/04/2016 |
|
article |
|
|
DLLExport |
|
|
|
d42f295b-35f9-49d2-9ee4-c66896ffe68e |
10 |
corob-msft |
corob |
ghogen |
Rotates bits to the left (_lrotl
) or right (_lrotr
).
unsigned long _lrotl(
unsigned long value,
int shift
);
unsigned long _lrotr(
unsigned long value,
int shift
);
value
Value to be rotated.
shift
Number of bits to shift value.
Both functions return the rotated value. There is no error return.
The _lrotl
and _lrotr
functions rotate value by shift
bits. _lrotl
rotates the value left. _lrotr
rotates the value right. Both functions wrap bits rotated off one end of value to the other end.
Routine | Required header |
---|---|
_lrotl |
<stdlib.h> |
_lrotr |
<stdlib.h> |
For more compatibility information, see Compatibility in the Introduction.
All versions of the C run-time libraries.
// crt_lrot.c
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
unsigned long val = 0x0fac35791;
printf( "0x%8.8lx rotated left eight times is 0x%8.8lx\n",
val, _lrotl( val, 8 ) );
printf( "0x%8.8lx rotated right four times is 0x%8.8lx\n",
val, _lrotr( val, 4 ) );
}
0xfac35791 rotated left eight times is 0xc35791fa
0xfac35791 rotated right four times is 0x1fac3579