Aracılığıyla paylaş


__popcnt16, __popcnt, __popcnt64

Microsoft'a Özgü

16, 32 veya 64 bit işaretsiz tamsayıdaki bit sayısını 1 (popülasyon sayısı) sayar.

Sözdizimi

unsigned short __popcnt16(
   unsigned short value
);
unsigned int __popcnt(
   unsigned int value
);
unsigned __int64 __popcnt64(
   unsigned __int64 value
);

Parametreler

value
[in] Popülasyon sayısını istediğimiz 16, 32 veya 64 bit işaretsiz tamsayı.

Dönüş değeri

Değer parametresindeki bit sayısı1.

Gereksinimler

Içsel Mimari
__popcnt16 Gelişmiş Bit Düzenleme
__popcnt Gelişmiş Bit Düzenleme
__popcnt64 64 bit modunda Gelişmiş Bit Düzenleme.

intrin.h üst bilgi dosyası<>

Açıklamalar

İçsel değerlerin her biri yönergeyi popcnt oluşturur. 32 bit modunda 64 bit genel amaçlı yazmaç yoktur, bu nedenle 64 bit popcnt desteklenmez.

Yönergeye popcnt yönelik donanım desteğini belirlemek için ile iç InfoType=0x00000001 öğesini çağırın __cpuid ve 23. bitini CPUInfo[2] (ECX)denetleyin. Yönerge destekleniyorsa bu bit 1, aksi takdirde 0 olur. Bu iç bilgileri kullanan kodu yönergeyi desteklemeyen popcnt bir donanımda çalıştırırsanız, sonuçlar tahmin edilemez.

Örnek

#include <iostream>
#include <intrin.h>
using namespace std;

int main()
{
  unsigned short us[3] = {0, 0xFF, 0xFFFF};
  unsigned short usr;
  unsigned int   ui[4] = {0, 0xFF, 0xFFFF, 0xFFFFFFFF};
  unsigned int   uir;

  for (int i=0; i<3; i++) {
    usr = __popcnt16(us[i]);
    cout << "__popcnt16(0x" << hex << us[i] << ") = " << dec << usr << endl;
  }

  for (int i=0; i<4; i++) {
    uir = __popcnt(ui[i]);
    cout << "__popcnt(0x" << hex << ui[i] << ") = " << dec << uir << endl;
  }
}
__popcnt16(0x0) = 0
__popcnt16(0xff) = 8
__popcnt16(0xffff) = 16
__popcnt(0x0) = 0
__popcnt(0xff) = 8
__popcnt(0xffff) = 16
__popcnt(0xffffffff) = 32

END Microsoft'a Özgü

Advanced Micro Devices, Inc. Tarafından Telif Hakkı 2007 Bölümleri Tüm hakları saklıdır. Reproduced with permission from Advanced Micro Devices, Inc.

Ayrıca bkz.

Derleyici iç bilgileri