_lrotl, _lrotr

Description

Rotate bits to the left (_lrotl) or right (_lrotr).

#include <stdlib.h>

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  

Remarks

The _lrotl and _lrotr functions rotate value by shift bits. The _lrotl function rotates the value left. The _lrotr function rotates the value right. Both functions “wrap” bits rotated off one end of value to the other end.

Return Value

Both functions return the rotated value. There is no error return.

Compatibility

Standards:None

16-Bit:DOS, QWIN, WIN, WIN DLL

32-Bit:DOS32X

See Also

_rotl, _rotr

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

xfac35791 rotated left eight times is 0xc35791fa

0xfac35791 rotated right four times is 0x1fac3579