_bittestandreset, _bittestandreset64
Microsoft 特定的
產生指示以檢查位址 a
的位 b
、傳回其目前值,並將位重設為 0。
語法
unsigned char _bittestandreset(
long *a,
long b
);
unsigned char _bittestandreset64(
__int64 *a,
__int64 b
);
參數
a
[in, out]要檢查之記憶體的指標。
b
[in]要測試的位位置。
傳回值
位於指定位置的位元。
需求
內建 | 架構 |
---|---|
_bittestandreset |
x86、ARM、x64、ARM64 |
_bittestandreset64 |
x64、ARM64 |
標頭檔 < intrin.h>
備註
此常式僅可作為內建常式使用。
範例
// bittestandreset.cpp
// processor: x86, IPF, x64
#include <stdio.h>
#include <limits.h>
#include <intrin.h>
#pragma intrinsic(_bittestandreset)
// Check the sign bit and reset to 0 (taking the absolute value)
// Returns 0 if the number is positive or zero
// Returns 1 if the number is negative
unsigned char absolute_value(long* p)
{
const int SIGN_BIT = 31;
return _bittestandreset(p, SIGN_BIT);
}
int main()
{
long i = -112;
unsigned char result;
// Check the sign bit and reset to 0 (taking the absolute value)
result = absolute_value(&i);
if (result == 1)
printf_s("The number was negative.\n");
}
The number was negative.
END Microsoft 特定的
另請參閱
意見反映
https://aka.ms/ContentUserFeedback。
即將推出:我們會在 2024 年淘汰 GitHub 問題,並以全新的意見反應系統取代並作為內容意見反應的渠道。 如需更多資訊,請參閱:提交及檢視以下的意見反映: