_bittestandreset, _bittestandreset64
Microsoft 전용
주소 a의 비트 b를 검사하고 현재 값을 반환한 다음 비트를 0으로 다시 설정하는 명령을 생성합니다.
unsigned char _bittestandreset( long *a, long b ); unsigned char _bittestandreset64( __int64 *a, __int64 b );
매개 변수
[in, out] a
검사할 메모리에 대한 포인터입니다.[in] b
테스트할 비트 위치입니다.
반환 값
지정한 위치에 있는 비트입니다.
요구 사항
내장 함수 |
아키텍처 |
---|---|
_bittestandreset |
x86, ARM, x64 |
_bittestandreset64 |
x64 |
헤더 파일 <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");
}