_lrotl, _lrotr
Rotate bits to the left (_lrotl) or right (_lrotr).
unsignedlong_lrotl(unsignedlongvalue**,intshift);**
unsignedlong_lrotr(unsignedlongvalue**,intshift);**
Routine | Required Header | Compatibility |
_lrotl | <stdlib.h> | Win 95, Win NT |
_lrotr | <stdlib.h> | Win 95, Win NT |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
LIBC.LIB | Single thread static library, retail version |
LIBCMT.LIB | Multithread static library, retail version |
MSVCRT.LIB | Import library for MSVCRT.DLL, retail version |
Return Value
Both functions return the rotated value. There is no error return.
Parameters
value
Value to be rotated
shift
Number of bits to shift value
Remarks
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.
Example
/* LROT.C */
#include <stdlib.h>
#include <stdio.h>
void 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 ) );
}
Output
0xfac35791 rotated left eight times is 0xc35791fa
0xfac35791 rotated right four times is 0x1fac3579
Floating-Point Support Routines
See Also _rotl, _rotr