Questions tagged [bitset]

A collection of bits organized as an array of bits, in which each bit can be accessed separately. For C++ bitsets, prefer the tag std-bitset

A collection of bits organized as an array of bits, in which each bit can be accessed separately.

Usage guidelines:

Related tags, with slighly differences:

751 questions
0
votes
0 answers

sparse binary matrix to bitset and applying Gauss

I have a large sparse binary matrix, and I have to apply the Gauss method , so I need to do a lot of logical (XOR) operations on the rows. In order to save space, I thought to use the bitset structure, but it has to be given a fixed dimension even…
Exodd
  • 221
  • 1
  • 9
0
votes
3 answers

Using bitset in place of using hand written bit manipulation code?

Is there any performance loss/gain using bitset in place where hand written? How to build the following using a bitset at runtime make all the bits between 2 and 5 as zero i.e., 11110011.
yesraaj
  • 46,370
  • 69
  • 194
  • 251
0
votes
2 answers

Having pointer to a template base class

In the following code, I've got an interface called IDecoder which should be implemented by any decoder class (DecoderA and DecoderB here). IDecoder has a bitset<> in it, therefore I've made IDecoder a template class and the size of bitset is…
B Faley
  • 17,120
  • 43
  • 133
  • 223
0
votes
1 answer

Bitset limitation, how to initialize integer at run-time in C++?

Now I've this code:- The code is about taking in an integer and providing its binary form in the given number of bits. #include #include using namespace std; int main(){ //creating instance using bitset (6 bit). here you…
0
votes
1 answer

JavaFX Property for a BitSet

I need a JavaFX Property for a BitSet in order to create a TableColumn with a toggle button for each bit in the BitSet. I have implemented Property but even with the oracle documentation the meaning and usage of some of the interface methods…
Konrad Höffner
  • 11,100
  • 16
  • 60
  • 118
0
votes
3 answers

Checking CRC using boost library does not give satisfactory result

I am using the boost crc library to calculate a 32-bit crc of an 112-bit (80-bit data + 32-bit crc) bitset. For testing, I reset all 80 data bits to 0. The calculation of the crc seems to work fine, but when I append the calculated crc to the data…
user3853511
  • 43
  • 1
  • 6
0
votes
0 answers

Checking certain positions on a pattern maching on bit vectors

I am sorry if the title was misleading, but I really did not know how to address this. Basically, the problem is the following: we have a bit vector T and a bit vector P. Let's say P[a1], P[a2], ..., P[ak] are the 1 bits in P. I am interested in…
lbicsi
  • 63
  • 1
  • 9
0
votes
1 answer

Java BitSet wrong conversion from/to byte array

Working with BitSets I have a failing test: BitSet bitSet = new BitSet(); bitSet.set(1); bitSet.set(100); logger.info("BitSet: " + BitSetHelper.toString(bitSet)); BitSet fromByteArray =…
Ignasi
  • 5,887
  • 7
  • 45
  • 81
0
votes
0 answers

c++ - arbitrary void* chunk to bitset

Suppose I have a method that receives a buffer of fixed lenght, like this: #define SIGN_SIZE 64 bitset chunkToBitset(void * chunk); Now, what I want is to create a bitset from the bits of that chunk of data (the size of the chunks is…
pedrostanaka
  • 711
  • 1
  • 9
  • 16
0
votes
1 answer

How to create a Bitset Array Queue?

I am reading in 14 byte messages from a device and I store them in an array of bitsets... bitset<8> currentMessage[14]; I want to create a queue of these messages. (Ideally I want the last 10 messages but I think that might be a whole other…
Kevvvvyp
  • 1,704
  • 2
  • 18
  • 38
0
votes
4 answers

Getting opposite results when using indices for bitset

I have a problem using bitsets from a char when I use indices. #include #include #include #include #include using namespace std; int main() { char c = 'C'; bitset<7> b(c); cout << b <<…
0
votes
1 answer

extract the index of bits set in a boost::dynamic_bitset

I have dynamic bitset in which I'm storing randomly generated integer values. Then I want to take blocks of n bits and check the indexes of the bits that are set to 1. At the end I'm treating the dynamic bitset as a sort of table. So what I want…
Hassingard
  • 108
  • 9
0
votes
2 answers

Printing std::bitset in C++11

Consider the following code written in C++11: #include #include #include int main() { std::uint64_t a = 0000000000000000000000000000000000000000000000001111111100000000; std::bitset<64> b(a); std::cout <<…
Romain
  • 1,385
  • 2
  • 15
  • 30
0
votes
2 answers

Return variably sized bitset

I was looking around for a way to return a bitset of varied size using a template or something similar. I haven't really had the chance to play around with it too much yet, but I was just curious if someone has ever messed with this before, and has…
Monatrox
  • 1
  • 1
0
votes
1 answer

Floating point to binary conversion

I am working on a project of converting any real number into binary using IEEE 754 format. My first trial is using the bitset library type for conversion of the number then i can worry about dividing the whole number into sign bit, exponent and…
Samuel
  • 612
  • 2
  • 9
  • 25