I am using a big number (over 128 bits integer) in my code. I find that c++ have std::bitset to simple some operation so I don't have to break my data into several integers. But I soon find another issue, if I have to convert several (long) integers into bitset, what's the best way to do that? For example, I am trying to convert four long integers (each of 32bits) to a 128bit bitset, the following way doesn't work because for each integers (the shift operation will only work for shifted bits less than 32)
std::bitset<256> b;
unsigned long v1=2, v2=9, v3=19, v4=1021;
b |= v1 | (v2<<32) | (v3<<64) | (v4<<128);
Now I use a for loop to set each bit on the bitset but I am looking for a more efficient and elegant way to do so.