Math module

log

procedure · 2 overloadsSource

The natural logarithm. log(0) is negative infinity, a negative or NaN argument gives NaN, and log(infinity) is infinity. float and float64; the float form computes in float64 and rounds. Written in Jai, so the last digit can differ from a C library's log.

ExampleOpen in playground ↗
assert(abs(log(cast(float64) 1)) < 0.0000001);
assert(abs(log(cast(float64) 2.718281828459045) - 1) < 0.0000001);
assert(log(cast(float64) 0) == -FLOAT64_INFINITY && isnan(log(cast(float64) -1)));
log :: (x: float64) -> float64

Natural logarithm. Negative or NaN gives NaN, zero gives negative infinity.

Parameters

x: float64
the value.

Returns

float64
log :: (x: float) -> float

Natural logarithm. Negative or NaN gives NaN, zero gives negative infinity.

Parameters

x: float
the value.

Returns

float

See also