#### Archived

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

# Converting fixed point to floating point

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

## 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 on other sites
Why are you using fixed point? Are you programming an 80386?

##### Share on other sites
Hehe no, I''m trying to read level files for an old game.

##### Share on other sites
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 on other sites
Ah, yes, that makes sense, thanks.

1. 1
2. 2
3. 3
Rutin
24
4. 4
JoeJ
18
5. 5

• 14
• 23
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631766
• Total Posts
3002228
×