_crotl, _crotr
Go Up to stdlib.h Index
Header File
stdlib.h
Category
Math Routines
Prototype
unsigned char _crotl(unsigned char val, int count);
unsigned char _crotr(unsigned char val, int count);
Description
Rotates an unsigned char left or right.
_crotl rotates the given val to the left count bits. _crotr rotates the given val to the right count bits.
The argument val is an unsigned char, or its equivalent in decimal or hexadecimal form.
Return Value
- The functions return the rotated byte:
- _crotl returns the value of val left-rotated count bits.
- _crotr returns the value of val right-rotated count bits.
Example
#include <stdlib.h>
#include <stdio.h>
/* function prototypes */
int crotl_example(void);
int crotl_example(void);
/* crotl example */
int crotl_example(void)
{
unsigned long result;
unsigned long value = 100;
result = _crotl(value,1);
printf("The value %lu rotated left one bit is: %lu\n", value, result);
return 0;
}
/* crotr example */
int crotr_example(void)
{
unsigned long result;
unsigned long value = 100;
result = _crotr(value,1);
printf("The value %lu rotated right one bit is: %lu\n", value, result);
return 0;
}
int main(void)
{
crotl_example();
crotr_example();
return 0;
}
Portability
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |