1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ビット配列(集合)の読み出し(シフト命令を使い任意の位置のビットを読み出す

Last updated at Posted at 2025-05-13

いろいろ、注意

  • UNOでの予定は、未定
  • ほぼ、年齢ぶん、プログラミングしているが、今まで1回も使わない(半世紀以上
  • 例題の為の例題
  • 元ネタは、競技プログラミング系または、純数学系、アカデミック
  • 論理的には、高速で高圧縮
  • データベースでビットテーブルやビットインデックステーブルがあるらしい(それは、使った事は、ある
  • はい、いいえだけを入れたテーブル(配列)
  • (概論)[論理]計算機学で出てるく内容だか実装は、下っ端がやるらいから(しらんらしい

プログラム

オンラインプログラムpaiza



#include <iostream>
using namespace std;

#define BS(aa,bb) ((aa[bb>>5]>>(bb&0x1f))&0x01)

int main(void){
    // Your code here!
    
    unsigned long abc[16];
    
    int a;
    
    abc[0] = 0x00000001;
    abc[1] = 0x80000000;
    
    a = BS(abc,0);
    
    printf("in [0],%d\n",a);

    a = BS(abc,63);
    
    printf("in [63],%d\n",a);
    
}




in [0],1
in [63],1

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?