Puzzle On Convertion of Float Data

Started by
4 comments, last by dave 17 years, 4 months ago
Hi,I am currently working on a data packeting program and I've got puzzle on data of float type.The manual said: The longitude(float) should be 28 bit,thus the hex should be 0x6791AC0. But my result is 0x435A8000. So I can't figure it out. Hope someone can help.
Advertisement
I'm not sure what there is to sort out.

So you can only send a 28 bit float in your packet, right?
Yes,only 28 bit for float.That is standard we cannot change.
I'm curious, how are your sending 28 bits down a socket, to my knowledge sockets send in characters. I assume you are appending two different pieces of information to gether into a float, or something. So like 28 bits of it are the longitude and the remaining 4 bits are some other variable.

Otherwise i cant see how you can send it down.

If the above is true, use bit masking and bit shifting to move things around the 32 bits of the float you are sending.

Dave
Well,the real problem is I do not kown which 4 bits to be cut out.
Any advice?
It is the most siginificant bits, the high-order bits, ie the ones worth the most. It firstly depends on the endianness of the machine so you need to find that out. It is most likely little endian, but you can't take that for granted. Google for an exaple of how to work out the endianness of a machine.

Dave

This topic is closed to new replies.

Advertisement