내보내기(0) 인쇄
모두 확장
확장 최소화

_BitScanReverse, _BitScanReverse64

Microsoft Specific

Search the mask data from most significant bit (MSB) to least significant bit (LSB) for a set bit (1).

unsigned char _BitScanReverse(
   unsigned long * Index,
   unsigned long Mask
);
unsigned char _BitScanReverse64(
   unsigned long * Index,
   unsigned __int64 Mask
);

[out] Index

Loaded with the bit position of the first set bit (1) found.

[in] Mask

The 32-bit or 64-bit value to search.

Nonzero if Index was set, or 0 if no set bits were found.

Intrinsic

Architecture

_BitScanReverse

x86, IPF, x64

_BitScanReverse64

IPF, x64

Header file <intrin.h>

// BitScanReverse.cpp
// compile with: /EHsc
#include <iostream>
#include <intrin.h>
using namespace std;

#pragma intrinsic(_BitScanReverse)



int main()
{
   unsigned long mask = 0x1000;
   unsigned long index;
   unsigned char isNonzero;
   
   cout << "Enter a positive integer as the mask: " << flush;
   cin >> mask;
   isNonzero = _BitScanReverse(&index, mask);
   if (isNonzero)
   {
      cout << "Mask: " << mask << " Index: " << index << endl;
   }
   else
   {
      cout << "No set bits found.  Mask is zero." << endl;
   }
}

Enter a positive integer as the mask: 
Mask: 12 Index: 3

커뮤니티 추가 항목

추가
Microsoft는 MSDN 웹 사이트에 대한 귀하의 의견을 이해하기 위해 온라인 설문 조사를 진행하고 있습니다. 참여하도록 선택하시면 MSDN 웹 사이트에서 나가실 때 온라인 설문 조사가 표시됩니다.

참여하시겠습니까?
표시:
© 2014 Microsoft