TI stores floating point numbers according to this structure:
struct FP { byte sign; // Whether the number is positive or negative byte exponent; // Locates the decimal point byte significand[7]; // The number itself byte guard[2]; // Guard digits for mathematics };The magnitude of every real number except zero can be represented as m × 10exp, where exp is an integer designating the exponent and m is a real number designating the significand such that 1 <= m < 10.
Examples:
$00, $9E, $23, $91, $80, $55, $75, $00, $00 2.391805575 × 1030 $80, $AC, $46, $19, $18, $45, $80, $00, $00 -4.61918458 × 1044 $80, $77, $75, $16, $99, $60, $94, $17, $87 -7.5169960941787 × 10-7 $00, $89, $19, $80, $61, $22, $02, $65, $10 1980612202.6510
If the number is complex, then this number is the real part (a). The imaginary part (b) is held in the next consecutive OP register, which also has bits 2 and 3 of its sign byte set.
Example:
$0C, $7E, $22, $09, $78, $47, $30, $00, $00 0.0220978473 - 0.0012565562i $8C, $7D, $12, $56, $55, $62, $00, $00, $00
_Mov9ToOP1 _Mov9ToOP2 |
Moves the nine bytes at HL to OP1 or OP2. | |
---|---|---|
INPUT | HL | Pointer to start of the nine bytes. |
DESTROYS | All but A | |
Remarks | For complex numbers, use _Mov9OP1OP2, which moves the 18 bytes at HL to OP1 and OP2. |
LD HL, exp b_call(_Mov9ToOP1) RET exp: .DB $00, $80, $27, $18, $28, $18, $28, $45, $94 ;2.7182818284594
Routine | Effect |
---|---|
_FPAdd | Adds OP2 to OP1. |
_FPDiv | Divides OP1 by OP2. |
_FPMult | Muliplies OP1 by OP2. |
_FPRecip | Reciprocal of OP1. OP2 = input OP1. |
_FPSub | Subtracts OP2 from OP1. |
_SqRoot | Square root of OP1. |
_Random | Gets a random number. 0.0 > OP1 > 1.0 |
_OPxToOPy | Stores 11 bytes at OPx to OPy. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DESTROYS | BC DE HL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Remarks | These combinations are available:
|
_OPxExOPy | Swaps 11 bytes at OPx with 11 bytes at OPy. | |||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DESTROYS | A BC DE HL | |||||||||||||||||||||||||||||||
Remarks | These combinations are available:
|
_DispOP1A | Displays the floating-point number in OP1 using the small font, formatted using the current FIX setting. | |
---|---|---|
INPUT | OP1 | Number |
A | Maximum number of characters (not digits) to display. | |
DESTROYS | All |
_FormReal | Converts the number in OP1 into a string. | |
---|---|---|
INPUT | OP1 | Number |
A | Maximum number of characters (not digits) to display, minimum of six. | |
OUTPUT | BC | Length of string |
OP3 | Start of string, null-terminated. | |
DESTROYS | All | |
Remarks | SCI, ENG, and FIX settings affect the string conversion. To ignore all format settings, use FormEReal. |
_ConvOP1 | Converts the number in OP1 into a two-byte integer. | |
---|---|---|
INPUT | OP1 | Number |
OUTPUT | DE | Converted number. |
Remarks | Generates an error if the exponent is greater than 3. |