Freigeben über


_bittestandreset, _bittestandreset64

Microsoft-spezifisch

Erzeugen Sie die Anweisung, die Bit b der Adresse a untersucht, den aktuellen Wert zurückgibt und das Bit auf 0 zurücksetzt.

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

Parameter

  • [in, out] a
    Ein Zeiger auf den zu untersuchenden Speicher.

  • [in] b
    Die zu testende Bitposition.

Rückgabewert

Das Bit an der angegebenen Position.

Anforderungen

Systemintern

Architektur

_bittestandreset

x86, ARM, x64

_bittestandreset64

x64

Headerdatei <intrin.h>

Hinweise

Diese Routine ist nur als systeminterne Funktion verfügbar.

Beispiel

// 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");   
}
  

Siehe auch

Referenz

Intrinsische Compilerfunktionen