Axle v0.14.1
Package

std/ffi/libm

libm math primitives. Cross-platform (POSIX + MSVCRT export the
same symbol set). libm is the C math library — historically
distinct from libc (linked -lm on Linux; folded into the CRT on
Windows/macOS), so it lives at std/ffi/libm, a sibling of
std/ffi/libc, not under it.

The single owning module for the libm transcendental bindings:
std/numeric/math consumes these via use std::ffi::libm; and
calls them as libm::sqrt(...). @link(symbol = …) pins each to its bare
libm symbol so the linker resolves it at user-program link time;
the libm:: namespace already disambiguates from the higher-level
std/numeric/math surface, so the bindings keep their plain names.

Free functions

TypeMethod and description
f64
sqrt(x : f64) : f64 Square root of x. Returns NaN for x < 0.
f64
cbrt(x : f64) : f64 Real cube root of x (defined for negative x).
f64
pow(base : f64, exponent : f64) : f64 base raised to exponent.
f64
hypot(x : f64, y : f64) : f64 Euclidean distance sqrt(x*x + y*y), computed without overflow.
f64
exp(x : f64) : f64 Base-e exponential e^x.
f64
log(x : f64) : f64 Natural (base-e) logarithm of x. Returns NaN for x < 0, -inf at 0.
f64
log2(x : f64) : f64 Base-2 logarithm of x.
f64
log10(x : f64) : f64 Base-10 logarithm of x.
f64
sin(x : f64) : f64 Sine of x, with x in radians.
f64
cos(x : f64) : f64 Cosine of x, with x in radians.
f64
tan(x : f64) : f64 Tangent of x, with x in radians.
f64
asin(x : f64) : f64 Arcsine of x, in radians over [-π/2, π/2]. Domain [-1, 1].
f64
acos(x : f64) : f64 Arccosine of x, in radians over [0, π]. Domain [-1, 1].
f64
atan(x : f64) : f64 Arctangent of x, in radians over (-π/2, π/2).
f64
atan2(y : f64, x : f64) : f64 Arctangent of y/x in radians over (-π, π], using the signs of both
arguments to select the correct quadrant.
f64
sinh(x : f64) : f64 Hyperbolic sine of x.
f64
cosh(x : f64) : f64 Hyperbolic cosine of x.
f64
tanh(x : f64) : f64 Hyperbolic tangent of x.
f64
floor(x : f64) : f64 Largest integral value not greater than x (rounds toward -inf).
f64
ceil(x : f64) : f64 Smallest integral value not less than x (rounds toward +inf).
f64
trunc(x : f64) : f64 Integral part of x, dropping the fraction (rounds toward zero).
f64
round(x : f64) : f64 Nearest integral value to x, rounding halves away from zero.
f64
fabs(x : f64) : f64 Absolute value of x.
f64
fmod(x : f64, y : f64) : f64 Floating-point remainder of x / y (same sign as x).

Method detail

#sqrt

sqrt(x : f64) : f64

Square root of x. Returns NaN for x < 0.

Parameters
x radicand; domain [0, +inf) for a real result.

#cbrt

cbrt(x : f64) : f64

Real cube root of x (defined for negative x).

Parameters
x radicand; whole real line.

#pow

pow(base : f64, exponent : f64) : f64

base raised to exponent.

Parameters
base the value to raise.
exponent the power to raise base to.

#hypot

hypot(x : f64, y : f64) : f64

Euclidean distance sqrt(x*x + y*y), computed without overflow.

Parameters
x first leg length.
y second leg length.

#exp

exp(x : f64) : f64

Base-e exponential e^x.

Parameters
x exponent.

#log

log(x : f64) : f64

Natural (base-e) logarithm of x. Returns NaN for x < 0, -inf at 0.

Parameters
x argument; domain (0, +inf).

#log2

log2(x : f64) : f64

Base-2 logarithm of x.

Parameters
x argument; domain (0, +inf).

#log10

log10(x : f64) : f64

Base-10 logarithm of x.

Parameters
x argument; domain (0, +inf).

#sin

sin(x : f64) : f64

Sine of x, with x in radians.

Parameters
x angle in radians.

#cos

cos(x : f64) : f64

Cosine of x, with x in radians.

Parameters
x angle in radians.

#tan

tan(x : f64) : f64

Tangent of x, with x in radians.

Parameters
x angle in radians.

#asin

asin(x : f64) : f64

Arcsine of x, in radians over [-π/2, π/2]. Domain [-1, 1].

Parameters
x argument; domain [-1, 1].

#acos

acos(x : f64) : f64

Arccosine of x, in radians over [0, π]. Domain [-1, 1].

Parameters
x argument; domain [-1, 1].

#atan

atan(x : f64) : f64

Arctangent of x, in radians over (-π/2, π/2).

Parameters
x argument; whole real line.

#atan2

atan2(y : f64, x : f64) : f64

Arctangent of y/x in radians over (-π, π], using the signs of both
arguments to select the correct quadrant.

Parameters
y numerator (vertical component).
x denominator (horizontal component).

#sinh

sinh(x : f64) : f64

Hyperbolic sine of x.

Parameters
x argument (a hyperbolic angle, not radians).

#cosh

cosh(x : f64) : f64

Hyperbolic cosine of x.

Parameters
x argument (a hyperbolic angle, not radians).

#tanh

tanh(x : f64) : f64

Hyperbolic tangent of x.

Parameters
x argument (a hyperbolic angle, not radians).

#floor

floor(x : f64) : f64

Largest integral value not greater than x (rounds toward -inf).

Parameters
x value to round down.

#ceil

ceil(x : f64) : f64

Smallest integral value not less than x (rounds toward +inf).

Parameters
x value to round up.

#trunc

trunc(x : f64) : f64

Integral part of x, dropping the fraction (rounds toward zero).

Parameters
x value to truncate.

#round

round(x : f64) : f64

Nearest integral value to x, rounding halves away from zero.

Parameters
x value to round.

#fabs

fabs(x : f64) : f64

Absolute value of x.

Parameters
x argument; whole real line.

#fmod

fmod(x : f64, y : f64) : f64

Floating-point remainder of x / y (same sign as x).

Parameters
x dividend.
y divisor.