_lrotl, _lrotr
Visual Studio .NET 2003
Rotate bits to the left (_lrotl) or right (_lrotr).
unsigned long _lrotl( unsigned long value, int shift ); unsigned long _lrotr( unsigned long value, int shift );
Parameters
- value
- Value to be rotated.
- shift
- Number of bits to shift value.
Return Value
Both functions return the rotated value. There is no error return.
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.
Requirements
| Routine | Required header | Compatibility |
|---|---|---|
| _lrotl | <stdlib.h> | Win 98, Win Me, Win NT, Win 2000, Win XP |
| _lrotr | <stdlib.h> | Win 98, Win Me, Win NT, Win 2000, Win XP |
For additional compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
Example
// 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 ) );
}
Output
0xfac35791 rotated left eight times is 0xc35791fa 0xfac35791 rotated right four times is 0x1fac3579
See Also
Floating-Point Support Routines | _rotl, _rotr | Run-Time Routines and .NET Framework Equivalents