fp-utils
Documentation
Additional float routines.
float Computations
Usage
(import fp-utils)N N1 ... X1 ... Y1 ... below are float.
P is the precision in decimal digits, an integer.
fpsummation
(fpsummation NUMS) -> floatReturns sum of NUMS via Kahan Summation Formula.
- NUMS
(list-of float).
fprandom
(fprandom [N]) -> floatReturns float in [0 1).
Nfixnumorfloatlimit.
fpmodulo
(fpmodulo N1 N2) -> floatfpquotient
(fpquotient N1 N2) -> floatfpremainder
(fpremainder N1 N2) -> floatfptruncate-with-precision
(fptruncate-with-precision N [P 4]) -> floatfpround-with-precision
(fpround-with-precision N [P 4]) -> floatfpceiling-with-precision
(fpceiling-with-precision N [P 4]) -> floatfpfloor-with-precision
(fpfloor-with-precision N [P 4]) -> floatfpmax-and-min
(fpmax-and-min N ...) -> (values float float)Returns the maximum & minimum values for the floats N ....
fpdistance
(fpdistance X1 Y1 X2 Y2) -> floatPythagorean distance between the points X1 Y1 and X2 Y2.
fpdistance*
(fpdistance* X1 Y1 X2 Y2) -> floatPythagorean distance, inaccurate but useful for relative comparisons.
fp~=
(fp~= N1 N2 [EPS float-epsilon]) -> floatCompare floating-point values N1 and N2 within some float epsilon EPS.
fp~<=
(fp~<= N) -> booleanfp~>=
(fp~>= N) -> booleanfloat Inlines
Usage
(import fp-inlines)N N1 ... X1 ... Y1 ... below are float.
P is the precision in decimal digits, an integer.
fpzero?
(fpzero? N) -> booleanfppositive?
(fppositive? N) -> booleanNote that -0.0 is not positive; (fl=? -0.0 0.0).
fpnatural?
(fpnatural? N) -> booleanNote that -0.0 is not cardinal; (fl=? -0.0 0.0).
fpnegative?
(fpnegative? N) -> booleanNote that -0.0 is not negative; (fl=? -0.0 0.0).
fpeven?
(fpeven? N) -> booleanfpodd?
(fpodd? N) -> booleanfpclosed-right?
fpclosedr?
Returns N in (L .. H].
N, L & H are float low & high limits.
fpclosed?
Returns N in [L .. H].
(fpclosed? L N H) -> booleanN, L & H are float low & high limits.
fpclosed-left?
fpclosedl?
Returns N in [L .. H).
N, L & H are float low & high limits.
fpadd1
(fpadd1 N) -> floatfpsub1
(fpsub1 N) -> floatfpfraction
(fpfraction N) -> floatfpsqr
(fpsqr N) -> floatfpcub
(fpcub N) -> floatfpavg
(fpavg N1 N2) -> floatfp%
(fp% N1 P) -> float: P ; (or float fixnum) ; percentage
fplog2
(fplog2 N) -> floatfplog10
(fplog10 N) -> floatfpdegree->radian
(fpdegree->radian N) -> floatfpradian->degree
(fpradian->degree N) -> floatfpprecision-factor
(fpprecision-factor P [BASE 10.0]) -> floatReturns factor for P decimal digits precision.
: P ; (or float fixnum) ; precision
fpprecision-epsilon
(fpprecision-epsilon P [BASE 10.0]) -> floatReturns inverse factor for P decimal digits precision.
: P ; (or float fixnum) ; precision
Author
Repository
This egg is hosted on the CHICKEN Subversion repository:
https://anonymous@code.call-cc.org/svn/chicken-eggs/release/5/fp-utils
If you want to check out the source code repository of this egg and you are not familiar with Subversion, see this page.
Version history
- 5.0.0
- C6 port.
License
This code is in the public domain.