the bitset does not serialize, so you don't need to (need) to know. Use serialization / deserialization.
- bitset <8> (). set (7) .to_ulong () is always 1
No, not on my car (see below).
However, I would certainly expect iostream operators to behave portablely:
#include <bitset> #include <sstream> #include <iostream> int main() { std::bitset<8> bits; std::cout << bits.set(7).to_ulong() << std::endl; std::stringstream ss; ss << bits; std::cout << ss.rdbuf() << std::endl; std::bitset<8> cloned; ss >> cloned; std::cout << cloned.set(7).to_ulong() << std::endl; std::cout << cloned << std::endl; }
Print
128 10000000 128 10000000
sehe
source share