_rotl8, _rotl16
Microsoft-spezifisch
Drehen Sie die Eingabewerte um eine angegebene Anzahl Bitpositionen nach links auf das höchstwertige Bit (MSB).
unsigned char _rotl8(
unsigned char value,
unsigned char shift
);
unsigned short _rotl16(
unsigned short value,
unsigned char shift
);
Parameter
[in] value
Der zu drehende Wert.[in] shift
Die Anzahl der zu drehenden Bits.
Rückgabewert
Der gedrehte Wert.
Anforderungen
Systemintern |
Architektur |
---|---|
_rotl8 |
x86, ARM, x64 |
_rotl16 |
x86, ARM, x64 |
Headerdatei <intrin.h>
Hinweise
Im Gegensatz zu Verschiebevorgängen nach links werden bei einem Drehvorgang nach links die hochwertigen Bits, die aus dem oberen Bereich herausfallen, an die Bitpositionen mit dem niedrigsten Wert verschoben.
Beispiel
// rotl.cpp
#include <stdio.h>
#include <intrin.h>
#pragma intrinsic(_rotl8, _rotl16)
int main()
{
unsigned char c = 'A', c1, c2;
for (int i = 0; i < 8; i++)
{
printf_s("Rotating 0x%x left by %d bits gives 0x%x\n", c,
i, _rotl8(c, i));
}
unsigned short s = 0x12;
int nBit = 10;
printf_s("Rotating unsigned short 0x%x left by %d bits gives 0x%x\n",
s, nBit, _rotl16(s, nBit));
}