_rotr8, _rotr16
Sezione specifica Microsoft
Ruotare i valori di input a destra del bit meno significativo di un numero specificato di posizioni di bit.
unsigned char _rotr8(
unsigned char value,
unsigned char shift
);
unsigned short _rotr16(
unsigned short value,
unsigned char shift
);
Parametri
[in] value
Valore da ruotare.[in] shift
Numero di bit da ruotare.
Valore restituito
Il valore ruotato.
Requisiti
Funzione intrinseca |
Architettura |
---|---|
_rotr8 |
x86, ARM, x64 |
_rotr16 |
x86, ARM, x64 |
File di intestazione <intrin.h>
Note
A differenza di un'operazione di spostamento a destra, quando si esegue una rotazione a destra, i bit di ordine inferiore che non rientrano nell'estremità inferiore vengono spostati nelle posizioni di bit di ordine superiore.
Esempio
// rotr.cpp
#include <stdio.h>
#include <intrin.h>
#pragma intrinsic(_rotr8, _rotr16)
int main()
{
unsigned char c = 'A', c1, c2;
for (int i = 0; i < 8; i++)
{
printf_s("Rotating 0x%x right by %d bits gives 0x%x\n", c,
i, _rotr8(c, i));
}
unsigned short s = 0x12;
int nBit = 10;
printf_s("Rotating unsigned short 0x%x right by %d bits "
"gives 0x%x\n",
s, nBit, _rotr16(s, nBit));
}