Compartilhar via


_bittestandreset, _bittestandreset64

Seção específica da Microsoft

Gere a instrução que examina o bit b do endereço a, retorna o valor atual dele e redefine o bit como 0.

Sintaxe

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

Parâmetros

a
[in, out] Um ponteiro para a memória a ser examinada.

b
[in] A posição de bit a ser testada.

Retornar valor

O bit na posição especificada.

Requisitos

Intrinsic Arquitetura
_bittestandreset x86, ARM, x64, ARM64
_bittestandreset64 x64, ARM64

Arquivo de cabeçalho<intrin.h>

Comentários

Essa rotina só está disponível como função intrínseca.

Exemplo

// 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.

Fim da seção específica da Microsoft

Confira também

Compilador intrínsecos