Menu

#54 bit shift in NovatelData.cpp

open
nobody
5
2011-01-14
2011-01-14
No

To parse log data from Novatel receiver, I grab some codes from line 985 in NovatelData.cpp to my application. Then I found unexpected locktime value returned from bitwise operations:

1014 double locktime = double((data[4] & 0xFFFF0000L) >> 16)
1015 + double(data[5] & 0x0000001FL);

The returned value of locktime is wrong. Finally I changed the codes to get right data:

double Locktime = (double) ( ((data[4] & 0xFFFF0000L)>>16)
+ ((data[5] & 0x0000001FL)<<16) );

My application runs on Linux with Intel Xeon CPU, so it's little endian. And I think there is nothing about endian.

Discussion