SagaSaga
Standard Library

Std.Math

Mathematical constants and functions for floating-point arithmetic.

Functions

pi

fun pi : Float

The ratio of a circle's circumference to its diameter.

e

fun e : Float

Euler's number, the base of the natural logarithm.

tau

fun tau : Float

Two times pi. The ratio of a circle's circumference to its radius.

sqrt

fun sqrt : Float -> Float

Square root. Panics on negative input.

pow

fun pow : Float -> Float -> Float

Raises the first argument to the power of the second.

log

fun log : Float -> Float

Natural logarithm (base e). Panics on non-positive input.

log2

fun log2 : Float -> Float

Base-2 logarithm. Panics on non-positive input.

log10

fun log10 : Float -> Float

Base-10 logarithm. Panics on non-positive input.

asin

fun asin : Float -> Float

Arcsine in radians. Input must be in [-1, 1].

acos

fun acos : Float -> Float

Arccosine in radians. Input must be in [-1, 1].

atan2

fun atan2 : Float -> Float -> Float

Two-argument arctangent in radians.

exp

fun exp : Float -> Float

Exponential function (e raised to the given power).

sin

fun sin : Float -> Float

Sine in radians.

cos

fun cos : Float -> Float

Cosine in radians.

tan

fun tan : Float -> Float

Tangent in radians.

atan

fun atan : Float -> Float

Arctangent in radians.

abs

fun abs : Float -> Float

Returns the absolute value.

min

fun min : Float -> Float -> Float

Returns the smaller of two floats.

max

fun max : Float -> Float -> Float

Returns the larger of two floats.

clamp

fun clamp : Float -> Float -> Float -> Float

Clamps a value to the range [low, high].

sign

fun sign : Float -> Float

Returns -1.0 for negative, 0.0 for zero, 1.0 for positive.

deg_to_rad

fun deg_to_rad : Float -> Float

Converts degrees to radians.

rad_to_deg

fun rad_to_deg : Float -> Float

Converts radians to degrees.