Grevle Posted March 4, 2020 Share Posted March 4, 2020 How to use "half numbers" like 0.2 and 0.5 and 0.8 and so on in Atari assembler ? do i have to create some sort of routine to do that kind of thing ?. Easiest way of setting up routines like that ? Quote Link to comment Share on other sites More sharing options...
Wrathchild Posted March 4, 2020 Share Posted March 4, 2020 How do you intend to use them? A staring point would be to read about fixed-point representation But you have alternatives such as using BCD math over a number of bytes and when displaying place a dot before the final digit. Or you can use the floating point package. Quote Link to comment Share on other sites More sharing options...
StickJock Posted March 4, 2020 Share Posted March 4, 2020 For me, from a firmware background, it's easiest to use fixed point numbers. For example, if you have 16 bits, you might have an 8.8, or a 10.6, or 12.4, depending on how much resolution you need. For these, instead of a decimal point, you have a binary point. The bits to the right of the binary point are your fractions. For base 10 (decimal), you have the tenths place, hundredths place, thousandths place, etc. For base 2 (binary), you have the halves place, quarters place, eights place, etc. Say that you only need 0..15 and you want to have a resolution of 1/16th. Then you can use a 4.4 fixed place notation. So $00 = 0.0 and $88 = 8.5, $C9 = 12.5625 (fraction = 9/16) and $FF = 15.9375 (fifteen and 15/16ths). Likewise, if you only need .25 increments, you could use a 6.2 notation, the above examples become $00 = 0.0, $88 = 34.0, $C9 = 50.25, $FF = 63.75. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.