The kernel provides functions for working with BCD-encoded floating point numbers. These are slower than binary floats but have greater accuracy in base 10. A binary floating point implementation are available in libc.
Takes the absolute value of the floating point number at IX.
Pointer to operand
Pointer to result
Adds the two floating point numbers.
Pointers to operands
Pointer to destination buffer
May destroy one or both operands.
Performs a logical AND on the two floating point numbers.
Pointers to operands
Result was true
Result was false
Compares the two floating point numbers.
Pointers to operands
same as z80 CP instruction
Calculates the fractional part of a floating point number, similar to TI-OS's fPart()
command.
Pointer to operand
Pointer to result
Calculates the integer part of a floating point number, similar to TI-OS's iPart()
command.
Pointer to operand
Pointer to result
Loads a floating point constant specified by A into HL.
Constant to load, use FP_*
macros from kernel.inc
Pointer to destination buffer
Finds the maximum of the two floating point numbers.
Pointers to operands
Pointer to maximum
Finds the minimum of the two floating point numbers.
Pointer to operands
Pointer to minimum
Multiplies the floating point number in IX by 10^E.
Pointer to operand
Signed exponent (i.e. 2 -> 100, -3 -> 0.001)
Pointer to result
Does not check for overflow.
Negates the floating point number at IX.
Pointer to operand
Pointer to result
Performs a logical NOT on the floating point number.
Pointer to operand
Result was true
Result was false
Performs a logical OR on the two floating point numbers.
Pointers to operands
Result was true
Result was false
Generates a random floating point number between 0 and 1, similar to TI-OS's rand
command.
Pointer to output
Uses getRandom
to generate the digits, so it is not cryptographically
random.
Subtracts the two floating point numbers.
Pointer to operand 2 (subtrahend)
Pointer to operand 1 (minuend)
Pointer to destination buffer
Performs a logical XOR on the two floating point numbers.
Pointers to operands
Result was true
Result was false
Converts a floating point number into an ASCII-encoded decimal string.
Flags / digits
Pointer to floating point number
Pointer to destination buffer
The destination buffer must be at least 20 characters in length.
The most significant nibble of A should be set to flags. FP_STR_*
macros in kernel.inc can be ORed and stored in A for convenience.
The least significant nibble of A is the number of digits to display after the decimal: 0-9 for that many digits, or 0xF for as many are non-zero.
Examples:
All nonzero decimals in scientific notation, with decimal as ',':
ld a, FP_STR_INV_PUNC | FP_DISP_SCIENTIFIC | 0xF
5 fixed digits grouped with ',':
ld a, FP_GROUP_DIGITS | 5
Converts a 32-bit unsigned integer into a floating-point binary coded decimal format and stores it to the buffer at HL.
Pointer to 9-byte destination buffer
Unsigned integer
The result is in the following format:
Converts an ASCII-encoded signed decimal into a floating-point binary coded decimal format and stores it to the buffer at HL.
Pointer to string
Pointer to 9-byte destination buffer
Set on success, reset on error
See itofp
for the result format.
Only the first 14 significant digits are converted. The rest are truncated but still used for exponent calculation.
In case of error, the destination buffer's contents are undefined.
The destination buffer must be zeroed before calling strtofp.