Compartilhar via


__ll_rshift

Microsoft Specific

Shifts a 64-bit value specified by the first parameter to the right by a number of bits specified by the second parameter.

__int64 __ll_rshift(
   __int64 Mask,
   int nBit
);

Parameters

  • [in] Mask
    The 64-bit integer value to shift right.

  • [in] nBit
    The number of bits to shift, modulo 64 on x64, and modulo 32 on x86.

Return Value

The mask shifted by nBit bits.

Requirements

Intrinsic

Architecture

__ll_rshift

x86, x64

Header file <intrin.h>

Remarks

If the second parameter is greater than 64 on x64 (32 on x86), that number is taken modulo 64 (32 on x86) to determine the number of bits to shift. The ll prefix indicates that this is an operation on long long, another name for __int64, the 64-bit signed integral type.

Example

// ll_rshift.cpp
// compile with: /EHsc
// processor: x86, x64
#include <iostream>
#include <intrin.h>
using namespace std;

#pragma intrinsic(__ll_rshift)

int main()
{
   __int64 Mask = - 0x100;
   int nBit = 4;
   cout << hex << Mask << endl;
   cout << " - " << (- Mask) << endl;
   Mask = __ll_rshift(Mask, nBit);
   cout << hex << Mask << endl;
   cout << " - " << (- Mask) << endl;
}

Output

ffffffffffffff00
 - 100
fffffffffffffff0
 - 10

Note   If _ull_rshift has been used, the MSB of the right-shifted value would have been zero, so the desired result would not have been obtained in the case of a negative value.

See Also

Reference

Compiler Intrinsics

__ll_lshift

__ull_rshift