• Advertisement

Archived

This topic is now archived and is closed to further replies.

Converting fixed point to floating point

This topic is 5084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I have a fixed point number where the low 16 bits is fractional, and the high 16 bits is the integer. I am not quite sure how it is encoded, but I assume there is a standard way. Say the number is this one: First 16 bit int: -1262 Last 16 bit int: 8973 Should this translate into (float)(-1262) - (float)8973 / 10000.0f = -1262.8973 or do I have to consider the last 16 bits as a fraction of the maximum value that 16 bits can have, ie: First 16 bit int: -1262 = 0x84ee Last 16 bit int: 8973 = 0x230d Translates into (float)(-1262) - (float)8973 / (float)0x0000ffff And the fraction part is unsigned anyway right? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I would think that it would be -1262.136917 or so. -1262 is the top 16 bits, and then the fractional portion would be divided by 2^16 (not 2^16 - 1, I believe). This way (in hex) .FFFF would equal 65535 / 65536, just as .9999 in decimal is 9999/10000.

Share this post


Link to post
Share on other sites

  • Advertisement