In c++. I initialize a bitset to -3 like:
std::bitset<32> mybit(-3);
Is there a grace way that convert mybit to -3
mybit
-3
Use to_ulong to convert it to unsigned long, then an ordinary cast to convert it to int.
to_ulong
unsigned long
int
int mybit_int; mybit_int = (int)(mybit.to_ulong());
DEMO