Archived

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

Arek the Absolute

Fixed point on the GBA...

Recommended Posts

Can someone explain how FIXED works in general? I''ve seen a few examples out there that use it (particularly Dovoto''s at the Pern Project) but I can''t quite figure out what''s going on. In case you''re not familiar with the term, it uses s32, or for that matter signed longs. I don''t quite get the hang of how you use it to apparently hold decimal numbers... And how you arrange the decimal part where it needs to go, etc.. If you can basically just explain it as a whole, or otherwise point me to something that does, it''d be much appreciated. -Arek the Absolute

Share this post


Link to post
Share on other sites
meh    375
After reading that tutorial link I''ve got confused. The basic idea of fixed point notation is that the decimal place is in a fixed position! Using an integer number to store this is relatively easy...


  

Normal:

2^ 7 6 5 4 3 2 1 0
bits 1 1 1 1 1 1 1 1 unsigned is 256 signed is -1

Fixed point:

2^ 3 2 1 0 -1 -2 -3 -4
bits 1 1 1 1 1 1 1 1 unsigned is 16.9375 signed is -1.9375

note: please check the numbers as they may be wrong :>



Addition and subtraction work as normal. But by multiplication and division cause the decimal point to move position and you will need to make adjustments (via bit shifts) to counter this.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
quote:
Original post by meh
After reading that tutorial link I''ve got confused. The basic idea of fixed point notation is that the decimal place is in a fixed position! Using an integer number to store this is relatively easy...



    

Normal:

2^ 7 6 5 4 3 2 1 0
bits 1 1 1 1 1 1 1 1 unsigned is 256 signed is -1

Fixed point:

2^ 3 2 1 0 -1 -2 -3 -4
bits 1 1 1 1 1 1 1 1 unsigned is 16.9375 signed is -1.9375

note: please check the numbers as they may be wrong :>



Addition and subtraction work as normal. But by multiplication and division cause the decimal point to move position and you will need to make adjustments (via bit shifts) to counter this.



That''s right. What are you confused about?

Share this post


Link to post
Share on other sites
meh    375
Nothing, I just mean''t the tutorial that was linked to is confusing... prehaps not the best way of expressing it but still. :>

Share this post


Link to post
Share on other sites