_rotl, _rotl64, _rotr, _rotr64
Rotates bits to the left (_rotl) or right (_rotr).
unsigned int _rotl( unsigned int value, int shift ); unsigned __int64 _rotl64( unsigned __int64 value, int shift ); unsigned int _rotr( unsigned int value, int shift ); unsigned __int64 _rotl64( unsigned __int64 value, int shift );
Parameters
- value
-
Value to be rotated.
- shift
-
Number of bits to shift.
| Routine | Required header | Compatibility |
|---|---|---|
| _rotl, _rotl64 | <stdlib.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
| _rotr, _rotr64 | <stdlib.h> | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 |
For more compatibility information, see Compatibility in the Introduction.
Libraries
All versions of the C run-time libraries.
// crt_rot.c
/* This program shifts values to rotate an integer.
*/
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
unsigned val = 0x0fd93;
__int64 val2 = 0x0101010101010101;
printf( "0x%4.4x rotated left three times is 0x%4.4x\n",
val, _rotl( val, 3 ) );
printf( "0x%4.4x rotated right four times is 0x%4.4x\n",
val, _rotr( val, 4 ) );
printf( "%I64x rotated left three times is %I64x\n",
val2, _rotl64( val2, 3 ) );
printf( "%I64x rotated right four times is %I64x\n",
val2, _rotr64( val2, 4 ) );
}
Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.