fp-utils

  1. fp-utils
  2. Documentation
    1. Flonum Computations
      1. Usage
      2. fpsummation
      3. fprandom
      4. fpmodulo
      5. fpquotient
      6. fpremainder
      7. fptruncate-with-precision
      8. fpround-with-precision
      9. fpceiling-with-precision
      10. fpfloor-with-precision
      11. fpmax-and-min
      12. fpdistance
      13. fpdistance*
      14. fp~=
      15. fp~<=
      16. fp~>=
    2. Flonum Inlines
      1. Usage
      2. fpzero?
      3. fppositive?
      4. fpcardinal?
      5. fpnegative?
      6. fpeven?
      7. fpodd?
      8. fpclosed-right?
      9. fpclosedr?
      10. fpclosed?
      11. fpclosed-left?
      12. fpclosedl?
      13. fpadd1
      14. fpsub1
      15. fpfraction
      16. fpsqr
      17. fpcub
      18. fplog2
      19. fplog10
      20. fpdegree->radian
      21. fpradian->degree
      22. fpprecision-factor
  3. Author
  4. Repository
  5. Version history
  6. License

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) -> flonum

Returns sum of NUMS via Kahan Summation Formula.

NUMS
(list-of float).

fprandom

[procedure] (fprandom [N]) -> flonum

Returns flonum in [0 1).

N
fixnum or flonum limit.

fpmodulo

[procedure] (fpmodulo N1 N2) -> flonum

fpquotient

[procedure] (fpquotient N1 N2) -> flonum

fpremainder

[procedure] (fpremainder N1 N2) -> flonum

fptruncate-with-precision

[procedure] (fptruncate-with-precision N [P 4]) -> flonum

fpround-with-precision

[procedure] (fpround-with-precision N [P 4]) -> flonum

fpceiling-with-precision

[procedure] (fpceiling-with-precision N [P 4]) -> flonum

fpfloor-with-precision

[procedure] (fpfloor-with-precision N [P 4]) -> flonum

fpmax-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) -> flonum

Pythagorean distance between the points X1 Y1 and X2 Y2.

fpdistance*

[procedure] (fpdistance* X1 Y1 X2 Y2) -> flonum

Pythagorean distance, inaccurate but useful for relative comparisons.

fp~=

[procedure] (fp~= N1 N2 [EPS flonum-epsilon]) -> flonum

Compare floating-point values N1 and N2 within some flonum epsilon EPS.

fp~<=

[procedure] (fp~<= N) -> boolean

fp~>=

[procedure] (fp~>= N) -> boolean

Flonum 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) -> boolean

fppositive?

[procedure] (fppositive? N) -> boolean

Note that -0.0 is not positive, due to (fl<? -0.0 0.0).

fpcardinal?

[procedure] (fpcardinal? N) -> boolean

Note that -0.0 is not cardinal, due to (fl<? -0.0 0.0).

fpnegative?

[procedure] (fpnegative? N) -> boolean

Note that -0.0 is not negative, due to (fl<? -0.0 0.0).

fpeven?

[procedure] (fpeven? N) -> boolean

fpodd?

[procedure] (fpodd? N) -> boolean

fpclosed-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) -> boolean

N, 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) -> flonum

fpsub1

[procedure] (fpsub1 N) -> flonum

fpfraction

[procedure] (fpfraction N) -> flonum

fpsqr

[procedure] (fpsqr N) -> flonum

fpcub

[procedure] (fpcub N) -> flonum

fplog2

[procedure] (fplog2 N) -> flonum

fplog10

[procedure] (fplog10 N) -> flonum

fpdegree->radian

[procedure] (fpdegree->radian N) -> flonum

fpradian->degree

[procedure] (fpradian->degree N) -> flonum

fpprecision-factor

[procedure] (fpprecision-factor P [BASE 10.0]) -> flonum

Returns factor for P decimal digits precision.

Author

Kon Lovett

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

4.0.0
C5 port.

License

This code is in the public domain.