_rotl, _rotl64, _rotr, _rotr64

Ruota i bit a sinistra (_rotl) o a destra (_rotr).

Sintassi


unsigned int _rotl(
   unsigned int value,
   int shift
);
unsigned __int64 _rotl64(
   unsigned __int64 value,
   int shift
);
unsigned int _rotr(
   unsigned int value,
   int shift
);
unsigned __int64 _rotr64(
   unsigned __int64 value,
   int shift
);

Parametri

value
Valore da ruotare.

shift
Numero di bit da spostare.

Valore restituito

Il valore ruotato. Non viene restituito alcun errore.

Osservazioni:

Le _rotl funzioni e _rotr ruotano i bit senza segno shiftvalue. _rotl ruota il valore a sinistra. _rotr ruota il valore a destra. Entrambe le funzioni eseguono il wrapping dei bit ruotati da un'estremità all'altra value .

Requisiti

Ciclo Intestazione obbligatoria
_rotl, _rotl64 <stdlib.h>
_rotr, _rotr64 <stdlib.h>

Per altre informazioni sulla compatibilità, vedere Compatibility (Compatibilità).

Librerie

Tutte le versioni delle librerie di runtime C.

Esempio

// crt_rot.c
/* This program shifts values to rotate an integer.
*/

#include <stdlib.h>
#include <stdio.h>

int main( void )
{
   unsigned val = 0x0fd93;
   __int64 val2 = 0x0101010101010101;

   printf( "0x%4.4x rotated left three times is 0x%4.4x\n",
           val, _rotl( val, 3 ) );
   printf( "0x%4.4x rotated right four times is 0x%4.4x\n",
           val, _rotr( val, 4 ) );

   printf( "%I64x rotated left three times is %I64x\n",
           val2, _rotl64( val2, 3 ) );
   printf( "%I64x rotated right four times is %I64x\n",
           val2, _rotr64( val2, 4 ) );
}

Output

0xfd93 rotated left three times is 0x7ec98
0xfd93 rotated right four times is 0x30000fd9
101010101010101 rotated left three times is 808080808080808
101010101010101 rotated right four times is 1010101010101010

Vedi anche

Supporto matematico e a virgola mobile
_lrotl, _lrotr