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

Compare int and bitset in c++

How can I compare bitset with an integer ? Or more generally work with integer operator: something like this : #include #include #include using namespace std; int main() { bitset<4> _b1 = 3 ; if(_b1>=2 ) …
Shahb
  • 47
  • 1
  • 6
0
votes
1 answer

Converting Bytes To BitSets

I am trying to figure out a way of taking data from a file and I want to store every 4 bytes as a bitset(32). I really have no idea of how to do this. I have played about with storing each byte from the file in an array and then tried to covert…
Karl
  • 31
  • 3
0
votes
1 answer

How to solve ClassCastException when using BitSet as key in Java Map

I am using: Map Mymap=new TreeMap<>(); When I try to call: Mymap.contains(someBitSetObject) I am getting following run time error: Exception in thread "main" java.lang.ClassCastException: java.util.BitSet cannot be cast to…
Kaur
  • 279
  • 1
  • 6
  • 18
0
votes
3 answers

Java bit comparison, bitset?

I've got the word 'bitset' stuck in my head as the solution to my problem but I think I might be getting myself confused. I've got a list of hex values that indicate certain conditions, such as: 0x0001 = Outside 0x20000000 = Blah... Now I'm reading…
Tony
  • 3,587
  • 8
  • 44
  • 77
0
votes
2 answers

Problems with small C++ bitset code

I have tried to write the following code into my compiler and compile it: #include #include using namespace std; void binary(int a) { cout << bitset<8>(a).to_string() << endl; } int…
mamta rani
  • 133
  • 1
  • 2
  • 7
0
votes
1 answer

realize Bitset function whose param is long

The set() function of BitSet is set(int param).I am trying to realize Bitset function by sending a long type.Are there any API or tutorial? thanks. BitSet mobiphoneUsers = new…
Felix
  • 1,253
  • 7
  • 22
  • 41
0
votes
1 answer

equivalent of .Find_first method for bitsets in visual studio

The title pretty much summarizes it. In gcc, you can use the .Find_first() method on a bitset to get the position of the first significant bit. Is there any equivalent in Visual Studio? I know you can use _BitScanForward64 in Visual Studio to get…
SMir
  • 650
  • 1
  • 7
  • 19
0
votes
2 answers

Behavior change from Rebol 2 to Rebol 3 for empty BITSET! testing; how to test EMPTY?

In Rebol 2 you could check for an empty bitset with EMPTY? >> empty? make bitset! #{00} == true In Rebol 3 (Build 21-Feb-2011/0:44:24) this is not the case. >> empty? make bitset! #{00} == false Bug or new behavior? Either way, how else might I…
0
votes
3 answers

Why, when trying to populate an array, am I getting a NullPointerException?

I'm trying to Populate an array of BitSets with information about an int array //ar is a SIZE*SIZE 1-D int array, SIZE is a constant //decare BitSet array BitSet bs[] = new BitSet[SIZE]; //initialize BitSet array for (BitSet…
1279343
  • 100
  • 8
0
votes
1 answer

std::bitset redeclaration

I would like to substract an integer from a number that my bitset represents. However, I don't know how to either a) copy a bitset to another bitset, or, b) re-instantiate a bitset: bitset<7> bits(5); int…
c0dehunter
  • 6,412
  • 16
  • 77
  • 139
0
votes
1 answer

c++; Is bitset the solution for me?

I am writing a program and using memcpy to copy some bytes of data, using the following code; #define ETH_ALEN 6 unsigned char sourceMAC[6]; unsigned char destMAC[6]; char* txBuffer; .... memcpy((void*)txBuffer, (void*)destMAC,…
jwbensley
  • 10,534
  • 19
  • 75
  • 93
0
votes
1 answer

Filling an int array with bits in a bitset.

#define CHAR_BIT 8 union { float input; // assumes sizeof(float) == sizeof(int) int output; } data; data.input = 122.5; bitset bits(data.output); int ieee[32]; for(int i = 0 ; i < 32 ; ++i){ …
freinn
  • 1,049
  • 5
  • 14
  • 23
0
votes
4 answers

Generate a random BitSet with n 1's

Possible Duplicate: Randomly pick k bits out of n from a Java BitSet Is there an easy way to generate a random BitSet of size n*n (e.g. 64) and exactly n (e.q 8) number of 1's in a random order? What Ive thought about is that I could possibly…
rtc11
  • 747
  • 8
  • 23
0
votes
1 answer

Pointing to array of bitsets

I wonder if the following construction is possible: typedef std::bitset<4> BIT4; BIT4* x=new BIT4[3]; BIT4* y=new BIT4[5]; My concerns are: (1) is the array of BIT4 a legal construction? (2) if yes, how the pointer will address these arrays of…
gartenzwerg
  • 237
  • 1
  • 2
  • 8
0
votes
2 answers

Installing vs2008 over vs2010

Because of bitset problem in vs2010, i will also install vs2008 which doesn't have that bug. But as i remember, in my old experiences, there were a few conflicts in windows sdk. I don't exactly remember but how can i fix these conflicts ? Or is…
deniz
  • 2,427
  • 4
  • 27
  • 38