_rotl, _rotl64, _rotr, _rotr64_rotl, _rotl64, _rotr, _rotr64

Gira los bits a la izquierda (_rotl) o a la derecha (_rotr).Rotates bits to the left (_rotl) or right (_rotr).

SintaxisSyntax


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
);

ParámetrosParameters

valuevalue
Valor que se va a girar.Value to be rotated.

shiftshift
Número de bits que se van a desplazar.Number of bits to shift.

Valor devueltoReturn Value

El valor girado.The rotated value. No se devuelve ningún error.There's no error return.

ObservacionesRemarks

Las funciones _rotl y _rotr giran el valor sin signo mediante el desplazamiento de bits.The _rotl and _rotr functions rotate the unsigned value by shift bits. _rotl gira el valor a la izquierda._rotl rotates the value left. _rotr gira el valor a la derecha._rotr rotates the value right. Ambas funciones ajustan los bits girados de un extremo de value al otro extremo.Both functions wrap bits rotated off one end of value to the other end.

RequisitosRequirements

RutinaRoutine Encabezado necesarioRequired header
_rotl, _rotl64_rotl, _rotl64 <stdlib.h>
_rotr, _rotr64_rotr, _rotr64 <stdlib.h>

Para obtener más información sobre compatibilidad, vea Compatibility.For more compatibility information, see Compatibility.

BibliotecasLibraries

Todas las versiones de las bibliotecas en tiempo de ejecución de C.All versions of the C run-time libraries.

EjemploExample

// 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 ) );
}

SalidaOutput

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

Vea tambiénSee also

Compatibilidad de punto flotanteFloating-Point Support
_lrotl, _lrotr_lrotl, _lrotr