Sign in to follow this  
Robinhood

Puzzle On Convertion of Float Data

Recommended Posts

Robinhood    122
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.

Share this post


Link to post
Share on other sites
dave    2187
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

Share this post


Link to post
Share on other sites
dave    2187
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this