Aye documentation

std.math

std.math: float math on `f64` (most functions are C's libm), and `minOf`, `maxOf`, `absOf` and `clampOf` on any integer type.

pi

pub let pi: f64 = 3.141592653589793

sqrt

pub extern fn sqrt(x: f64) f64

The square root; NaN for a negative `x`.

floor

pub extern fn floor(x: f64) f64

The largest integer value not above `x`.

ceil

pub extern fn ceil(x: f64) f64

The smallest integer value not below `x`.

round

pub extern fn round(x: f64) f64

The nearest integer value; halfway cases go away from zero.

pow

pub extern fn pow(x: f64, y: f64) f64

`x` to the power `y`.

trunc

pub extern fn trunc(x: f64) f64

`x` without its fraction: the integer value toward zero.

fmod

pub extern fn fmod(x: f64, y: f64) f64

The remainder of `x / y`, with the sign of `x`.

sin

pub extern fn sin(x: f64) f64

The sine of `x` (radians).

cos

pub extern fn cos(x: f64) f64

The cosine of `x` (radians).

tan

pub extern fn tan(x: f64) f64

The tangent of `x` (radians).

asin

pub extern fn asin(x: f64) f64

The arc sine, in `-pi/2..=pi/2`; NaN outside `-1..=1`.

acos

pub extern fn acos(x: f64) f64

The arc cosine, in `0..=pi`; NaN outside `-1..=1`.

atan

pub extern fn atan(x: f64) f64

The arc tangent, in `-pi/2..=pi/2`.

atan2

pub extern fn atan2(y: f64, x: f64) f64

The angle of the point `(x, y)`, in `-pi..=pi`.

exp

pub extern fn exp(x: f64) f64

`e` to the power `x`.

log

pub extern fn log(x: f64) f64

The natural logarithm; NaN for a negative `x`, `-inf()` for 0.

log2

pub extern fn log2(x: f64) f64

The base-2 logarithm.

log10

pub extern fn log10(x: f64) f64

The base-10 logarithm.

hypot

pub extern fn hypot(x: f64, y: f64) f64

`sqrt(x * x + y * y)`, without overflow in between.

sign

pub fn sign(x: f64) f64

-1, 0 or 1 by the sign of `x` (0 for -0.0 too); NaN for a NaN.

min

pub fn min(a: f64, b: f64) f64

The smaller of `a` and `b`.

max

pub fn max(a: f64, b: f64) f64

The larger of `a` and `b`.

abs

pub fn abs(x: f64) f64

`x` without its sign.

inf

pub fn inf() f64

Positive infinity (`-inf()` is negative infinity).

nan

pub fn nan() f64

A NaN ("not a number"). It is not equal to anything, itself included: test with `isNan`.

isNan

pub fn isNan(x: f64) bool

Is `x` a NaN?

isInf

pub fn isInf(x: f64) bool

Is `x` infinite (either sign)?

clamp

pub fn clamp(x: f64, lo: f64, hi: f64) f64

`x` limited to `lo..=hi`.

minOf

pub fn minOf(comptime T: type, a: T, b: T) T where T: Integer

The smaller of two integers of type `T`: `minOf(i32, a, b)`.

maxOf

pub fn maxOf(comptime T: type, a: T, b: T) T where T: Integer

The larger of two integers of type `T`.

absOf

pub fn absOf(comptime T: type, x: T) T where T: Integer

The absolute value of an integer; overflows (a panic) for the most negative value of a signed type.

clampOf

pub fn clampOf(comptime T: type, x: T, lo: T, hi: T) T where T: Integer

`x` limited to `lo..=hi`.