_bittestandreset, _bittestandreset64

Блок, относящийся только к системам Майкрософт

Создайте инструкцию для изучения бита b адреса a, возврата текущего значения и сброса бита до 0.

Синтаксис

unsigned char _bittestandreset(
   long *a,
   long b
);
unsigned char _bittestandreset64(
   __int64 *a,
   __int64 b
);

Параметры

a
[in, out] Указатель на память для проверки.

b
[in] Битовое положение для тестирования.

Возвращаемое значение

Разряд на указанной позиции.

Требования

Intrinsic Архитектура
_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.

Завершение блока, относящегося только к системам Майкрософт

См. также

Встроенные компоненты компилятора