c0dehunter
c0dehunter

Reputation: 6150

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 newresult=bits.to_ulong();
newresult=newresult-1;
bits=bitset<7> tempbits(newresult); // of course doesn't work

It is important that my end result is in bits bitset. How to do it properly?

Upvotes: 0

Views: 140

Answers (1)

Robᵩ
Robᵩ

Reputation: 168626

bits = bitset<7>(newresult);  

Upvotes: 5

Related Questions