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
3 answers

How do i unset the kth set bit in binary string

Here i have a binary string, for example - "01010011". The positions of set bits are = 0, 1, 4, 6 (from right to left). I have to do series of operations something like this. for binary string - 01010011 unset the 0th set bit. - 01010010 (new set…
Atul
  • 546
  • 4
  • 16
0
votes
1 answer

How to test std::bitset for randomness?

I create random bitsets with following code below. Now I wanna write some test and asking myself how to test the randomness of bitsets? Is there a good solution to this problem? As bitsets can not be represented as numbers AFAIK, I don't know hot to…
user1587451
  • 978
  • 3
  • 15
  • 30
0
votes
3 answers

C - Difference between bitset vector and bloom filter

So I understand that bitset vectors can essentially store true/false sets for you in each bit, however I'm confused as to the difference between that and a bloom filter, I understand bloom filters make use of hashing functions and can return false…
realicado
  • 172
  • 7
0
votes
1 answer

How can I work with bitsets in R?

How can I work with bitsets in R? I googled and found bit and pack packages but I'm not sure it's what I need. I have big raw object that is loaded from DB which is array of bytes. I want to access it as if it was bitset to have following…
expert
  • 29,290
  • 30
  • 110
  • 214
0
votes
1 answer

How can I express this elements to c++

Hi I'd like express this into c++ vector< bitset<8>> s{ s1, s2,..., sn }; n is the number of the element in the file. So, I made cnt to count the elements in the file. So, I made this code. But I think my code is not right. But I don't know how to…
rose.b
  • 31
  • 1
0
votes
1 answer

read string from file and turn into bitset<12>

Hi I'm trying to read string from txt file and transform it into binary file which is bitset<12> string form. int main() { using namespace std; std::ifstream f("fruit.txt"); std::ofstream out("result.txt"); std::hashhash_fn; int…
jack
  • 11
  • 3
0
votes
2 answers

bitset and numerical sequence C++

Im learning C++ at the minute with book by Stanley Lippman. Im studying paragraph that named "class Bitset". There is an exercise where he gives me numerical sequence to transfrom into bitset<32>. The numerical sequence is: 1,2,3,5,8,13,21. Can i…
FishTheBig
  • 71
  • 1
  • 1
  • 7
0
votes
1 answer

Combining two part of a word with a part of another word and using a scale factor

I am trying to extract data from a GPS receiver. The way they transmit their information is shown in the following figure. I am trying to get roota. I have word 8 and word 9 in seperate bitsets. How do I combine the relevant bits into one bitset? I…
Ariel Baron
  • 331
  • 4
  • 13
0
votes
1 answer

How to load/read binary file into an "vector >" in c++?

I have a problem with loading/reading an vector > (called/typedef'ed as population in my code) which it stored using the following code: void genetic_algorithm::save_generation(population pop_to_save, string filename){ …
0
votes
1 answer

Unable to make function call in template argument

The following program compiles fine. #include #include int main() { const int r = std::sqrt(100); std::bitset n; } $ g++ -Wall -Wextra -pedantic -std=c++11 foo.cpp $ But the following program fails to compile. #include…
Lone Learner
  • 18,088
  • 20
  • 102
  • 200
0
votes
1 answer

Why is this bitset collection algorithm not working?

Here's my goal: Create all possible bit strings of length N. Once I've created a possible string, I want to take B bits at time, covert them to a index, and use that index to fetch a character from the following string: define ALPHABET…
Objective-J
  • 319
  • 1
  • 2
  • 13
0
votes
0 answers

How can write and read a java bitset from python?

I am using the chemistry development kit to calculate 'fingerprints' for chemical structures. I would like to save these in an sql database, but Im note sure what the best way to store and then read the data. I am currently using python because…
Peaksandpeaks
  • 57
  • 1
  • 8
0
votes
1 answer

Use of dynamic bitset to convert decimal numbers

I am solving a leetcode problem, which the output need to be a binary number without abundant digits. I have the decimal number and I was trying to use bitset to do the conversion. I wrote a function to return the number of digit given the number…
Wenzhen
  • 1
  • 4
0
votes
1 answer

Is Java BitSet get() method read only?

I have code which creates an array of size N BitSets. At the start of execution, I do some calculations and then set the bits in the corresponding array indexe to act as a filtering process. For example, if I get given the number 10 and position…
0
votes
0 answers

How to implement bitset binary exclusion used to find code?

I am new to C++, and I need to write a code that can find a binary code by checking a bitset against inputs and excluding unnecessary options. Example: input-000000000 = 6 correct This implies that there must be 3 ones present. I need the code to…
Zeus _
  • 1
  • 2