|
|
- NAME
- #include <libraries/mathffp.h>
#include <proto/mathffp.h>
float SPFloor ()
- SYNOPSIS
- float y
- FUNCTION
- Calculate the largest integer ffp-number less than or equal to
fnum
- INPUTS
- y
- FFP number
- RESULT
- FFP number
Flags:
zero : result is zero
negative : result is negative
overflow : 0 (???)
- NOTES
-
- EXAMPLE
- floor(10.5) = 10
floor(0.5) = 0
floor(-0.5) = -1
floor(-10.5)= -11
- BUGS
-
- SEE ALSO
- MathFFP.library, IEEESPCeil(), IEEESPFloor(), SPCeil()
- INTERNALS
- ALGORITHM:
The integer part of a ffp number are the left "exponent"-bits
of the mantisse!
Therefore:
Test the exponent for <= 0. This has to be done separately!
If the sign is negative then return -1 otherwise return 0.
Generate a mask of exponent(y) (where y is the given ffp-number)
bits starting with bit 31.
If y < 0 then test whether it is already an integer. If not
then y = y - 1 and generate that mask again. Use the
mask on the mantisse.
|