_rotl, _rotr (Windows CE 5.0)

Send Feedback

Developing an Application > Microsoft C Run-time Library for Windows CE > Run-time Library Reference

Rotate bits to the left (_rotl) or right (_rotr).

unsigned int _rotl(    unsigned intvalue,intshift);unsigned int _rotr(    unsigned intvalue,intshift);

Parameters

  • value
    Value to be rotated.
  • shift
    Number of bits to shift.

Return Values

Both functions return the rotated value.

There is no error return.

Remarks

The _rotl and _rotr functions rotate the unsigned value by shift bits.

_rotl rotates the value left.

_rotr rotates the value right.

Both functions wrap bits rotated off one end of value to the other end.

Example

/* ROT.C: This program uses _rotr and _rotl with
 * different shift values to rotate an integer.
 */

#include <stdlib.h>
#include <stdio.h>

void main( void )
{
   unsigned val = 0x0fd93;
   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 ) );
}

Output

0xfd93 rotated left three times is 0x7ec98
0xfd93 rotated right four times is 0x30000fd9

Requirements

OS Versions: Windows CE 2.0 and later.
Header: stdlib.h.
Link Library: coredll.dll.

See Also

_lrotl

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.