Module ce_math

Description

Mathematics and arithmetic library.

Function Index

Exported Functions
base/2Formats an integer into a string in base N, or parses a string in base N into an integer.
ceil/1Returns the next highest integer of a value.
ceil/2Returns the next highest multiple of N.
deg_to_rad/1Converts degrees to radians.
fact/1Returns the factorial of the given integer.
fib/1Returns the nth term in the Fibonacci squence [1,1,2,3,5,8,13...].
fix/1Returns the next lowest integer to the given number.
floor/1See fix/1.
gcf/2Computes the greatest common factor of two integers.
lcm/2Computes the least common multiple of two integers.
max/2Returns the greater of two values.
min/2Returns the lesser of two values.
rad_to_deg/1Converts radians to degrees.
sgn/1Returns +1, 0, or -1, depending on the argument's sign.

Exported Functions

base/2

base(Base::integer(), Value::integer() | string()) -> string() | integer()

Formats an integer into a string in base N, or parses a string in base N into an integer. Throws an error if the given string is not a well-formed number in base N.

ceil/1

ceil(number()) -> integer()

Returns the next highest integer of a value. Complements trunc.

ceil/2

ceil(number(), number()) -> number()

Returns the next highest multiple of N.

deg_to_rad/1

deg_to_rad(number()) -> number()

Converts degrees to radians.

fact/1

fact(integer()) -> integer()

Returns the factorial of the given integer.

fib/1

fib(integer()) -> integer()

Returns the nth term in the Fibonacci squence [1,1,2,3,5,8,13...]

fix/1

fix(number()) -> integer()

Returns the next lowest integer to the given number.

floor/1

floor(number()) -> integer()

Equivalent to fix(number()).

gcf/2

gcf(integer(), integer()) -> integer()

Computes the greatest common factor of two integers. This code was borrowed from Scott Gasch (who borrowed it from Euclid) and translated into Erlang.

lcm/2

lcm(integer(), integer()) -> integer()

Computes the least common multiple of two integers.

max/2

max(term(), term()) -> term()

Returns the greater of two values.

min/2

min(term(), term()) -> term()

Returns the lesser of two values.

rad_to_deg/1

rad_to_deg(number()) -> number()

Converts radians to degrees.

sgn/1

sgn(number()) -> integer()

Returns +1, 0, or -1, depending on the argument's sign.