分享方式:


__ll_rshift

Microsoft 特定的

將第一個參數所指定的 64 位值向右移位,由第二個參數指定的位數。

語法

__int64 __ll_rshift(
   __int64 Mask,
   int nBit
);

參數

面具
[in]要向右移位的 64 位整數值。

nBit
[in]要移位的位數、x64 上的模數 64 和 x86 上的模數 32。

傳回值

遮罩會以 nBit 位移位。

需求

內建 架構
__ll_rshift x86、x64

標頭檔 < intrin.h>

備註

如果第二個參數在 x64 上大於 64 (x86 上的 32 個),則該數位會採用模數 64 (x86 上的 32 個),以決定要移位的位數。 前置 ll 詞表示它是 上的 long long 作業,另一個名稱為 __int64 ,則為 64 位帶正負號的整數類型。

範例

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

輸出

ffffffffffffff00
- 100
fffffffffffffff0
- 10

注意

如果 _ull_rshift 已使用,則右移值的 MSB 會是零,因此在負值的情況下,不會取得所需的結果。

END Microsoft 特定的

另請參閱

編譯器內建函式
__ll_lshift
__ull_rshift