0 Members and 3 Guests are viewing this topic.
Hi,first things first, this is my 1st question on ASM programming!The question is: how easy (or hard) is it to use floats?if easy, please qive some codethanks in advance!
Quick tutorial:Floating point numbers are stored differently than you're used to. It's still stored the same way, but it's a data structure in itself.Each floating point number is 9 bytes, stored one after the other, always in scientific notation. For example, this is what -1337 looks like:SignExpS0S1S2S3S4S5S6$80$83$13$37$00$00$00$00$00Sign/Number Line (Sign)Bit 7 (the bit furthest to the left when you write it out) tells you whether it's positive or negative, while bits 2 and 3 tell you whether it's real or complex. In other words:If this byte is:Then the number is:%00000000Positive and real%10000000Negative and real%00001100Positive and complex%10001100Negative and complexSo in this case, it would be %10000000, or $80.Exponent (Exp)Here's where the fun starts. Floating points are always stored in scientific notation (as in -1.337x103), so you need to know what power of 10 it's being taken to. In this case, it would be three.But you don't just store a three here; no, that would be too easy, and remember that TI wants to screw us up. So instead, you add $80 to whatever the exponent is, then store it. So for -1337, or -1.337x103, it would be 3 + $80, or $83.Significand (S0-S6)This is the actual number itself. There are 7 bytes per number, each of which holds two digits (hence the 14 digits of accuracy on a TI-83 Plus series calc).It's stored in BCD (binary-coded decimal) format, in which each nibble holds a decimal digit (0-9). So a valid byte in the significand would be one of the following:$00-$09$10-$19$20-$29$30-$39$40-$49$50-$59$60-$69$70-$79$80-$89$90-$99The first digit (upper nibble of S0) is the characteristic, or the number before the decimal point when written in scientific notation (the 1 in -1.337x103).You could actually store a non-BCD value there (such as $BA). It causes some interesting effects when you try doing math with it Also, when the calculator actually operates on floating-point numbers (when you give it something to calculate), it adds two more bytes to the significand (making the significand 9 bytes and the entire number 11 bytes). This is so it has two more bytes of precision to work with.All right, so that's a floating-point number. When do you use it? FP is nearly always used for math, because it's inherently slow and cumbersome to work with. So if you want to use it for scores in a game, don't bother (unless for some reason you're working with 14-digit numbers).
Exponent (Exp)Here's where the fun starts. Floating points are always stored in scientific notation (as in -1.337x103), so you need to know what power of 10 it's being taken to. In this case, it would be three.But you don't just store a three here; no, that would be too easy, and remember that TI wants to THISscrew us up. So instead, you add $80 to whatever the exponent is, then store it. So for -1337, or -1.337x103, it would be 3 + $80, or $83.
Thanks! downloaded it immediately!