RAD Studio
ContentsIndex
PreviousUpNext
_rotl, _rotr

Header File 

stdlib.h  

Category 

Math Routines 

Prototype 

unsigned short _rotl(unsigned short value, int count); 

unsigned short _rotr(unsigned short value, int count); 

Description 

Bit-rotates an unsigned short integer value to the left or right. 

_rotl rotates the given value to the left count bits. 

_rotr rotates the given value to the right count bits. 

Return Value 

_rotl, and _rotr return the rotated integer:

  • _rotl returns the value of value left-rotated count bits.
  • _rotr returns the value of value right-rotated count bits.
Example

#include <stdlib.h>
#include <stdio.h>
/* rotl example */
int rotl_example(void)
{
   unsigned value, result;
   value = 32767;
   result = _rotl(value, 1);
   printf("The value %u rotated left one bit is: %u\n", value, result);
   return 0;
}
/* rotr example */
int rotr_example(void)
{
   unsigned value, result;
   value = 32767;
   result = _rotr(value, 1);
   printf("The value %u rotated right one bit is: %u\n", value, result);
   return 0;
}
int main(void)
{
   rotl_example();
   rotr_example();
   return 0;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
_rotl  
 
+  
 
 
_rotr  
 
 
 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!