You are looking at historical revision 39385 of this page. It may differ significantly from its current revision.
fp-utils
Documentation
Additional flonum routines.
Flonum Computations
Usage
(import fp-utils)
N N1 ... X1 ... Y1 ... below are flonum.
P is the precision in decimal digits, an integer.
fpsummation
[procedure] (fpsummation NUMS) -> flonumReturns sum of NUMS via Kahan Summation Formula.
- NUMS
- (list-of float).
fprandom
[procedure] (fprandom [N]) -> flonumReturns flonum in [0 1).
- N
- fixnum or flonum limit.
fpmodulo
[procedure] (fpmodulo N1 N2) -> flonumfpquotient
[procedure] (fpquotient N1 N2) -> flonumfpremainder
[procedure] (fpremainder N1 N2) -> flonumfptruncate-with-precision
[procedure] (fptruncate-with-precision N [P 4]) -> flonumfpround-with-precision
[procedure] (fpround-with-precision N [P 4]) -> flonumfpceiling-with-precision
[procedure] (fpceiling-with-precision N [P 4]) -> flonumfpfloor-with-precision
[procedure] (fpfloor-with-precision N [P 4]) -> flonumfpmax-and-min
[procedure] (fpmax-and-min N ...) -> (values flonum flonum)Returns the maximum & minimum values for the flonums N ....
fpdistance
[procedure] (fpdistance X1 Y1 X2 Y2) -> flonumPythagorean distance between the points X1 Y1 and X2 Y2.
fpdistance*
[procedure] (fpdistance* X1 Y1 X2 Y2) -> flonumPythagorean distance, inaccurate but useful for relative comparisons.
fp~=
[procedure] (fp~= N1 N2 [EPS flonum-epsilon]) -> flonumCompare floating-point values N1 and N2 within some flonum epsilon EPS.
fp~<=
[procedure] (fp~<= N) -> booleanfp~>=
[procedure] (fp~>= N) -> booleanFlonum Inlines
Usage
(import fp-inlines)
N N1 ... X1 ... Y1 ... below are flonum.
P is the precision in decimal digits, an integer.
fpzero?
[procedure] (fpzero? N) -> booleanfppositive?
[procedure] (fppositive? N) -> booleanNote that -0.0 is not positive, due to (fl<? -0.0 0.0).
fpcardinal?
[procedure] (fpcardinal? N) -> booleanNote that -0.0 is not cardinal, due to (fl<? -0.0 0.0).
fpnegative?
[procedure] (fpnegative? N) -> booleanNote that -0.0 is not negative, due to (fl<? -0.0 0.0).
fpeven?
[procedure] (fpeven? N) -> booleanfpodd?
[procedure] (fpodd? N) -> booleanfpclosed-right?
fpclosedr?
[procedure] (fpclosed-right? L N H) -> boolean[procedure] (fpclosedr? L N H) -> boolean
Returns N in (L .. H].
N, L & H are flonum low & high limits.
fpclosed?
Returns N in [L .. H].
[procedure] (fpclosed? L N H) -> booleanN, L & H are flonum low & high limits.
fpclosed-left?
fpclosedl?
Returns N in [L .. H).
[procedure] (fpclosed-left? L N H) -> boolean[procedure] (fpclosedl? L N H) -> boolean
N, L & H are flonum low & high limits.
fpadd1
[procedure] (fpadd1 N) -> flonumfpsub1
[procedure] (fpsub1 N) -> flonumfpfraction
[procedure] (fpfraction N) -> flonumfpsqr
[procedure] (fpsqr N) -> flonumfpcub
[procedure] (fpcub N) -> flonumfplog2
[procedure] (fplog2 N) -> flonumfplog10
[procedure] (fplog10 N) -> flonumfpdegree->radian
[procedure] (fpdegree->radian N) -> flonumfpradian->degree
[procedure] (fpradian->degree N) -> flonumfpprecision-factor
[procedure] (fpprecision-factor P [BASE 10.0]) -> flonumReturns factor for P decimal digits precision.
Author
Version history
- 4.0.0
- C5 port.
License
This code is in the public domain.