mochinum

Useful numeric algorithms for floats that cover some deficiencies
in the math module.

Useful numeric algorithms for floats that cover some deficiencies
in the math module. More interesting is digits/1, which implements
the algorithm from:
http://www.cs.indiana.edu/~burger/fp/index.html
See also "Printing Floating-Point Numbers Quickly and Accurately"
in Proceedings of the SIGPLAN '96 Conference on Programming Language
Design and Implementation.

Functions

digits(N::number()) -> string()

Returns a string that accurately represents the given integer or float
using a conservative amount of digits. Great for generating
human-readable output, or compact ASCII serializations for floats.

frexp(F::float()) -> {Frac::float(), Exp::float()}

Return the fractional and exponent part of an IEEE 754 double,
equivalent to the libc function of the same name.
F = Frac * pow(2, Exp).

int_ceil(F::float()) -> integer()

Return the ceiling of F as an integer. The ceiling is defined as
F when F == trunc(F);
trunc(F) when F < 0;
trunc(F) + 1 when F > 0.