I am trying to extract data from a GPS receiver. The way they transmit their information is shown in the following figure.
I am trying to get roota. I have word 8 and word 9 in seperate bitsets. How do I combine the relevant bits into one bitset?
I also need to use this scale factor information to get a double precision number. The scale factor information is shown below.
I have tried
std::bitset<32> word8_binary; // is filled with word 8 data.
std::bitset<32> word9_binary; // is filled with word 9 data.
std::bitset<32> roota_binary;
for (int i=13; i>5; i--)
{
roota_binary = word8_binary[i] << 32 | word9_binary[i];
}
But this is not giving me the result I want. I also don't know how to sue the scale factor.
Your help would be much appreciated.
This might not be "c++" enough, but I'd do bit manipulation on the corresponding integers:
ulong roota_binary = (((word8_binary.to_ulong() >> 6) & 0xFF) <<24) +
((word9_binary.to_ulong() >>6) & 0xFFFFFF);
The >>6
gets rid of the parity bits, the masks isolate the bits you need, and the <<24
puts the high ones on top.