0

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?

c0dehunter
  • 6,412
  • 16
  • 77
  • 139

1 Answers1

5
bits = bitset<7>(newresult);  
Robᵩ
  • 163,533
  • 20
  • 239
  • 308