2017-08-27

part of sph-lib

(sph number)

- absolute-difference
- average
- bit->byte-length
- bound
- bound-max
- bound-min
- call-with-product-then-divide
- container-length->number-max
- decrement-one
- float-sum
- fraction
- in-between?
- in-range?
- increment-one
- integer-and-fraction
- log-base
- number-container-length
- number-format-float
- percent
- round-to-decimal-places
- round-to-increment
- truncate-to-decimal-places

procedure### signature

### description

n-1 n-2 ->

number number -> number

result in the non-negative difference of two numbers

procedure### signature

### description

a ... ->

number ... -> number

calculate the average of the given numbers

procedure### signature

### description

a ->

integer -> integer

calculate the bytes required to store the number of bits

procedure### signature

### description

n min max ->

number number -> number

if n is smaller than min, return min.

if n is greater than max, return max

syntax### signature

a max

syntax### signature

a min

procedure### signature

### description

f a factor ->

procedure:{number -> number} number number -> number

call f with "a" multiplied by factor and afterwards divide by factor

procedure### signature

### description

digit-count base ->

integer integer -> integer

calculate the maximum value that can represented with the given number of digits in the given base

procedure### signature

a ->

procedure### signature

### description

a ... ->

return the sum of the given numbers calculated with rounding error compensation.

uses kahan summation with neumaier modification

procedure### signature

a ->

procedure### signature

### description

n start end ->

number number number -> boolean

true if n is between and not equal to num-start or num-end

procedure### signature

### description

n start end ->

number number number -> boolean

true if n is between or equal to start or end

procedure### signature

a ->

procedure### signature

### description

a c ->

number procedure:{integer real -> any:result} -> any:result

splits a number into its integer and fractional part. example: 1.74 -> 1 0.74

procedure### signature

### description

a base ->

number number -> number

result in the logarithm with "base" of "a"

procedure### signature

### description

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### signature

### description

a #:decimal-min #:decimal-max #:truncate* #:base ->

number

procedure### signature

### description

value base ->

how many percent is value from base

procedure### signature

a decimal-places ->

number number -> number

procedure### signature

### description

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### signature

a decimal-places ->

number number -> number