(sph number)

part of sph-lib

module name

(sph number)

exported bindings

procedure: bit->byte-length a ->
integer -> integer
calculate the bytes required to store the number of bits
procedure: bound n min max ->
number number -> number
if n is smaller than min, return min.
if n is greater than max, return max
syntax: bound-max a max
syntax: bound-min a min
procedure: call-with-product-then-divide f a factor ->
procedure:{number -> number} number number -> number
call f with \"a\" multiplied by factor and afterwards divide by factor
procedure: container-length->number-max digit-count base ->
integer integer -> integer
calculate the maximum value that can represented with the given number of digits in the given base
procedure: decrement-one a ->
procedure: float-modulo a b ->
modulo for float values. fmod
procedure: float-nearly-equal a b margin ->
approximate float comparison. margin specifies the greatest accepted difference
procedure: float-sum a ... ->
return the sum of the given numbers calculated with rounding error compensation.
uses kahan summation with neumaier modification
procedure: fraction a ->
procedure: in-between? n start end ->
number number number -> boolean
true if n is between and not equal to num-start or num-end
procedure: in-range? n start end ->
number number number -> boolean
true if n is between or equal to start or end
procedure: increment-one a ->
procedure: integer-and-fraction a c ->
procedure: log-base a base ->
number number -> number
result in the logarithm with \"base\" of \"a\"
procedure: number-container-length a base ->
integer:positive-integer integer -> integer
results in the number of vector elements of size base required to store the individual digits of the given positive number in the given base.
example use case is calculating the size of a bytevector for storing an integer
procedure: number-format-float a #:decimal-min #:decimal-max #:truncate* #:base ->
procedure: round-to-decimal-places a decimal-places ->
number number -> number
procedure: round-to-increment a increment ->
number number -> number
round a number to the the nearest multiple of \"increment\" (using \"round\").
if the number is exactly half-way in between increments, take the lower increment multiple.
example: (1.1 3) -> 0, (1.6 3) -> 3, (1.5 3) -> 0
procedure: truncate-to-decimal-places a decimal-places ->
number number -> number