mathffp.library Reference¶
Comprehensive function reference for mathffp.library, synthesised from the AmigaOS NDK 3.2 Release 4 (Autodocs/AG/mathffp).
This page documents 12 functions of mathffp.library. Each function entry follows the canonical autodoc format. struct Name, union Name, enum Name are clickable links to the type definition in the types reference.
Function index¶
SPAbs()¶
SPAbs -- Obtain the absolute value of the fast floating point number.
Synopsis
fnum2 = SPAbs(fnum1)
D0 D0
float SPAbs(float fnum1);
Function
Accepts a floating point number and returns the absolute value of said number.
Inputs
fnum1 - floating point number.
Results
fnum2 - floating point absolute value of fnum1.
Bugs
None
SPAdd()¶
SPAdd -- Add two floating point numbers.
Synopsis
fnum3 = SPAdd(fnum1, fnum2)
D0 D1 D0
float SPAdd(float fnum1, float fnum2);
Function
Accepts two floating point numbers and returns the arithmetic sum of said numbers.
Inputs
fnum1 - floating point number to add. fnum2 - other floating point number to add.
Results
fnum3 - floating point number, sum of fnum1 and fnum2.
Bugs
None.
SPCeil()¶
SPCeil -- Compute Ceil function of a number.
Synopsis
x = SPCeil(y)
D0 D0
float SPCeil(float y);
Function
Calculate the least integer greater than or equal to x and return it. This identity is true. Ceil(x) = -Floor(-x).
Inputs
y - Motorola Fast Floating Point Format Number.
Results
x - Motorola Fast Floating Point Format Number.
Bugs
None.
See also
SPCmp()¶
SPCmp -- Compares two floating point numbers.
Synopsis
result = SPCmp(fnum1, fnum2)
D0 D1 D0
int SPCmp(float fnum1, float fnum2);
Function
Accepts two floating point numbers and returns the condition codes set to indicate the result of said comparison. Additionally, the integer functional result is returned to indicate the result of said comparison.
Inputs
fnum1 - floating point number. fnum2 - floating point number.
Results
Condition codes set to reflect the following branches:
GT - fnum2 > fnum1
GE - fnum2 >= fnum1
EQ - fnum2 = fnum1
NE - fnum2 != fnum1
LT - fnum2 < fnum1
LE - fnum2 <= fnum1
Integer functional result as:
+1 => fnum1 > fnum2
-1 => fnum1 < fnum2
0 => fnum1 = fnum2
Bugs
The return value in the condition codes is REALLY the inverse of the result signalled in D0.
Unlike what former documentations said, this function expects fnum1
in D1 not in D0, and fnum2 in D0, not D1, similar to all other
mathffp functions. This has always been like it, and it will not
change in the future. Earlier autodocs were incorrect. Note that the
".fd" files are correct, i.e. compiler prototypes are correct.
This has the following consequences: If compared with the IEEE
libraries, which expect the first argument in the lower, not higher
registers, the result as returned in the condition codes is as if
you compare D0 with D1, consistently throughout all math models,
including this function, FFP and IEEE math. If you look, however,
at the argument position as function call from C, the condition
codes are exactly the inverse as one would expect. Luckely, if
called explicitly as a C function from C code, the condition codes
are not reachable and hence irrelevant.
Because the return value in D0 is the inverse of the condition
codes, unlike IEEE math, the return value in D0 reflects the
comparison of the first argument with the second (+1 if first
argument > second), but because the first argument is in D1, this is
the inverse of the IEEE return result if looked at the register
allocation, but the same argument if looked at the argument
position. Hence, again, if called explicitly from C, the result is
consistent with that of of IEEE math, but just because the register
allocation is the inverse.
SPDiv()¶
SPDiv -- Divide two floating point numbers.
Synopsis
fnum3 = SPDiv(fnum1, fnum2)
D0 D1 D0
float SPDiv(float fnum1, float fnum2);
Function
Accepts two floating point numbers and returns the quotient of the second argument divided by the first.
Inputs
fnum1 - floating point number. fnum2 - floating point number.
Results
fnum3 - floating point number.
Bugs
Former autodocs did not document which register is the divisor and which the divident. The divisor is the first argument, in register D1, the divident is the second argument in D0. Note that the register allocation is identical to that of the IEEE math functions, but the order of the function arguments is exactly the inverse of IEEE. Former releases crashed with a divide-by-zero exception if the divisor was zero. This release returns the largest positive or negative number, depending on the signs of the arguments. Unfortunately, this also holds for the divison of 0 by 0.
SPFix()¶
SPFix -- Convert fast floating point number to integer.
Synopsis
inum = SPFix(fnum)
D0 D0
int SPFix(float fnum);
Function
Accepts a floating point number and returns the truncated integer portion of said number.
Inputs
fnum - floating point number.
Results
inum - signed integer number.
Bugs
None.
SPFloor()¶
SPFloor -- compute Floor function of a number.
Synopsis
x = SPFloor(y)
D0 D0
float SPFloor(float y);
Function
Calculate the largest integer less than or equal to x and return it.
Inputs
y - Motorola Fast Floating Point number.
Results
x - Motorola Fast Floating Point number.
Bugs
None.
See also
SPFlt()¶
SPFlt -- Convert integer number to fast floating point.
Synopsis
fnum = SPFlt(inum)
D0 D0
float SPFlt(inet inum);
Function
Accepts an integer and returns the converted floating point result of said number.
Inputs
inum - signed integer number
Results
fnum - floating point number
Bugs
None.
SPMul()¶
SPMul -- Multiply two floating point numbers.
Synopsis
fnum3 = SPMul(fnum1, fnum2)
D0 D1 D0
float SPMul(float fnum1, float fnum2);
Function
Accepts two floating point numbers and returns the arithmetic multiplication of said numbers.
Inputs
fnum1 - floating point number fnum2 - floating point number
Results
fnum3 - floating point number
Bugs
None
SPNeg()¶
SPNeg -- Negate the supplied floating point number.
Synopsis
fnum2 = SPNeg(fnum1)
D0 D0
float SPNeg(float fnum1);
Function
Accepts a floating point number and returns the value of said number after having been subtracted from 0.0.
Inputs
fnum1 - floating point number.
Results
fnum2 - floating point negation of fnum1.
Bugs
None
SPSub()¶
SPSub -- Subtract two floating point numbers.
Synopsis
fnum3 = SPSub(fnum1, fnum2)
D0 D1 D0
float SPSub(float fnum1, float fnum2);
Function
Accepts two floating point numbers and subtracts the first argument from the second.
Inputs
fnum1 - floating point number. fnum2 - floating point number.
Results
fnum3 - floating point number.
Bugs
Former attempts to document this function did not make clear which argument is subtracted from which.
Note that the order of subtraction is identical to
the order of subtraction of IEEE math if looked at
the register allocation. but the *inverse* of the
IEEE model if looked at the position of the function
arguments, i.e. IEEE math subtracts the second argument
from the first.
SPTst()¶
SPTst - Compares a float against zero (0.0).
Synopsis
result = SPTst(fnum)
D0 D1
int SPTst(float fnum);
Function
Accepts a floating point number and returns the condition codes set to indicate the result of a comparison against the value of zero (0.0). Additionally, the integer functional result is returned.
Inputs
fnum - floating point number.
Results
Condition codes set to reflect the following branches:
EQ - fnum = 0.0
NE - fnum != 0.0
PL - fnum >= 0.0
MI - fnum < 0.0
Integer functional result as:
+1 => fnum > 0.0
-1 => fnum < 0.0
0 => fnum = 0.0
Bugs
None.