_lrotl, _lrotr
Nach oben zu stdlib.h - Index
Header-Datei
stdlib.h
Kategorie
Mathematische Routinen
Prototyp
unsigned long _lrotl(unsigned long val, int count);
unsigned long _lrotr(unsigned long val, int count);
Beschreibung
Rotiert einen Integerwert des Typs unsigned long nach links oder rechts.
_Irotl verschiebt die Bits des übergebenen Werts val um count Bits nach links. _lrotr verschiebt die Bits des übergebenen Werts val um count Bits nach rechts.
Rückgabewert
Die Funktionen geben den bit-verschobenen Integerwert zurück:
- _lrotl gibt den Wert des um count Bits nach links verschobenen Parameters val zurück.
- _lrotr gibt den Wert des um count Bits nach rechts verschobenen Parameters val zurück.
Beispiel
#include <stdlib.h>
#include <stdio.h>
/* Funktionsprototypen */
int lrotl_example(void);
int lrotr_example(void);
/* lrotl-Beispiel */
int lrotl_example(void)
{
unsigned long result;
unsigned long value = 100;
result = _lrotl(value,1);
printf("The value %lu rotated left one bit is: %lu\n", value, result);
return 0;
}
/* lrotr-Beispiel */
int lrotr_example(void)
{
unsigned long result;
unsigned long value = 100;
result = _lrotr(value,1);
printf("The value %lu rotated right one bit is: %lu\n", value, result);
return 0;
}
int main(void)
{
lrotl_example();
lrotr_example();
return 0;
}
Portabilität
| POSIX | Win32 | ANSI C | ANSI C++ |
|---|---|---|---|
|
+ |