_rotl8, _rotl16
Microsoft'a Özgü
Giriş değerlerini sola doğru belirtilen sayıda bit konumuyla en önemli bite (MSB) döndürün.
Sözdizimi
unsigned char _rotl8(
unsigned char value,
unsigned char shift
);
unsigned short _rotl16(
unsigned short value,
unsigned char shift
);
Parametreler
value
[in] Döndürülecek değer.
vardiya
[in] Döndürülecek bit sayısı.
Dönüş değeri
Döndürülen değer.
Gereksinimler
Içsel | Mimari |
---|---|
_rotl8 |
x86, ARM, x64, ARM64 |
_rotl16 |
x86, ARM, x64, ARM64 |
intrin.h üst bilgi dosyası<>
Açıklamalar
Sol kaydırma işleminden farklı olarak, sol döndürme yürütülürken, üst uçtan düşen yüksek sıralı bitler en az önemli bit konumlarına taşınır.
Örnek
// 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));
}
Rotating 0x41 left by 0 bits gives 0x41
Rotating 0x41 left by 1 bits gives 0x82
Rotating 0x41 left by 2 bits gives 0x5
Rotating 0x41 left by 3 bits gives 0xa
Rotating 0x41 left by 4 bits gives 0x14
Rotating 0x41 left by 5 bits gives 0x28
Rotating 0x41 left by 6 bits gives 0x50
Rotating 0x41 left by 7 bits gives 0xa0
Rotating unsigned short 0x12 left by 10 bits gives 0x4800
END Microsoft'a Özgü