分享方式:


__shiftleft128

Microsoft 特定的

移位 128 位元數量,表示兩個距離左邊達 LowPart 指定之位元數的 64 位元數量 HighPartShift,並傳回結果的較高 64 個位元。

語法

unsigned __int64 __shiftleft128(
   unsigned __int64 LowPart,
   unsigned __int64 HighPart,
   unsigned char Shift
);

參數

LowPart
[in]要轉移之 128 位數量的低 64 位。

HighPart
[in]要轉移之 128 位數量的高 64 位。

Shift 鍵
[in]要移位的位數。

傳回值

結果的較高 64 個位元。

需求

內建 架構
__shiftleft128 x64

標頭檔 < intrin.h>

備註

Shift 值一律為模數 64,因此,例如,如果您呼叫 __shiftleft128(1, 0, 64) ,函式會將低部分位移出左移,並傳回 的高部分 00 ,否則不會 1 如預期般。

範例

// shiftleft128.c
// processor: IPF, x64
#include <stdio.h>
#include <intrin.h>

#pragma intrinsic (__shiftleft128, __shiftright128)

int main()
{
    unsigned __int64 i = 0x1I64;
    unsigned __int64 j = 0x10I64;
    unsigned __int64 ResultLowPart;
    unsigned __int64 ResultHighPart;

    ResultLowPart = i << 1;
    ResultHighPart = __shiftleft128(i, j, 1);

    // concatenate the low and high parts padded with 0's
    // to display correct hexadecimal 128 bit values
    printf_s("0x%02I64x%016I64x << 1 = 0x%02I64x%016I64x\n",
             j, i, ResultHighPart, ResultLowPart);

    ResultHighPart = j >> 1;
    ResultLowPart = __shiftright128(i, j, 1);

    printf_s("0x%02I64x%016I64x >> 1 = 0x%02I64x%016I64x\n",
             j, i, ResultHighPart, ResultLowPart);
}
0x100000000000000001 << 1 = 0x200000000000000002
0x100000000000000001 >> 1 = 0x080000000000000000

END Microsoft 特定的

另請參閱

__shiftright128
編譯器內建函式