2017-08-27

(sph number)

part of sph-lib

bindings

import name

(sph number)

exports

absolute-difference

procedure

signature

n-1 n-2 ->

number number -> number

description

result in the non-negative difference of two numbers

average

procedure

signature

a ... ->

number ... -> number

description

calculate the average of the given numbers

bit->byte-length

procedure

signature

a ->

integer -> integer

description

calculate the bytes required to store the number of bits

bound

procedure

signature

n min max ->

number number -> number

description

if n is smaller than min, return min.

if n is greater than max, return max

bound-max

syntax

signature

a max

bound-min

syntax

signature

a min

call-with-product-then-divide

procedure

signature

proc a factor ->

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

description

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

container-length->number-max

procedure

signature

digit-count base ->

integer integer -> integer

description

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

decrement-one

procedure

signature

a ->

float-sum

procedure

signature

a ... ->

description

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

uses kahan summation with neumaier modification

fraction

procedure

signature

a ->

in-between?

procedure

signature

n start end ->

number number number -> boolean

description

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

in-range?

procedure

signature

n start end ->

number number number -> boolean

description

true if n is between or equal to start or end

increment-one

procedure

signature

a ->

integer-and-fraction

procedure

signature

a c ->

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

description

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

log-base

procedure

signature

a base ->

number number -> number

description

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

number-container-length

procedure

signature

a base ->

integer:positive-integer integer -> integer

description

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

number-format-float

procedure

signature

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

description

number

percent

procedure

signature

value base ->

description

how many percent is value from base

round-to-decimal-places

procedure

signature

a decimal-places ->

number number -> number

round-to-increment

procedure

signature

a increment ->

number number -> number

description

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

truncate-to-decimal-places

procedure

signature

a decimal-places ->

number number -> number


tags: programming guile documentation library scheme sph-lib number sph-number