math

Note: parts of this file are platform-conditional (#if).

Functions: abs, clamp, sin, cos, tan, asin, acos, atan, atan2, sinh, cosh, tanh, exp, exp2, log, log2, log10, pow, sqrt, cbrt, hypot, ceil, floor, trunc, round, fmod

Constants: pi, e

abs

T abs<T>(T value)

Returns the absolute value.

clamp

T clamp<T>(T value, T min, T max)

Constrains the value to the given range.

sin

extern float64 sin(float64 x);

Returns the sine of x.

float sin(float x)

Returns the sine of x.

cos

extern float64 cos(float64 x);

Returns the cosine of x.

float cos(float x)

Returns the cosine of x.

tan

extern float64 tan(float64 x);

Returns the tangent of x.

float tan(float x)

Returns the tangent of x.

asin

extern float64 asin(float64 x);

Returns the arc sine of x.

float asin(float x)

Returns the arc sine of x.

acos

extern float64 acos(float64 x);

Returns the arc cosine of x.

float acos(float x)

Returns the arc cosine of x.

atan

extern float64 atan(float64 x);

Returns the arc tangent of x.

float atan(float x)

Returns the arc tangent of x.

atan2

extern float64 atan2(float64 y, float64 x);

Returns the arc tangent of y/x.

float atan2(float y, float x)

Returns the arc tangent of y/x.

sinh

extern float64 sinh(float64 x);

Returns the hyperbolic sine of x.

float sinh(float x)

Returns the hyperbolic sine of x.

cosh

extern float64 cosh(float64 x);

Returns the hyperbolic cosine of x.

float cosh(float x)

Returns the hyperbolic cosine of x.

tanh

extern float64 tanh(float64 x);

Returns the hyperbolic tangent of x.

float tanh(float x)

Returns the hyperbolic tangent of x.

exp

extern float64 exp(float64 x);

Returns e raised to the power x.

float exp(float x)

Returns e raised to the power x.

exp2

extern float64 exp2(float64 x);

Returns 2 raised to the power x.

float exp2(float x)

Returns 2 raised to the power x.

log

extern float64 log(float64 x);

Returns the natural logarithm of x.

float log(float x)

Returns the natural logarithm of x.

log2

extern float64 log2(float64 x);

Returns the base-2 logarithm of x.

float log2(float x)

Returns the base-2 logarithm of x.

log10

extern float64 log10(float64 x);

Returns the base-10 logarithm of x.

float log10(float x)

Returns the base-10 logarithm of x.

pow

extern float64 pow(float64 x, float64 y);

Returns x raised to the power y.

float pow(float x, float y)

Returns x raised to the power y.

sqrt

extern float64 sqrt(float64 x);

Returns the square root of x.

float sqrt(float x)

Returns the square root of x.

cbrt

extern float64 cbrt(float64 x);

Returns the cube root of x.

float cbrt(float x)

Returns the cube root of x.

hypot

extern float64 hypot(float64 x, float64 y);

Returns the square root of the sum of the squares of x and y.

float hypot(float x, float y)

Returns the square root of the sum of the squares of x and y.

ceil

extern float64 ceil(float64 x);

Rounds x up to an integer.

float ceil(float x)

Rounds x up to an integer.

floor

extern float64 floor(float64 x);

Rounds x down to an integer.

float floor(float x)

Rounds x down to an integer.

trunc

extern float64 trunc(float64 x);

Rounds x toward zero to an integer.

float trunc(float x)

Rounds x toward zero to an integer.

round

extern float64 round(float64 x);

Rounds x to the nearest integer.

float round(float x)

Rounds x to the nearest integer.

fmod

extern float64 fmod(float64 x, float64 y);

Returns the remainder of x/y.

float fmod(float x, float y)

Returns the remainder of x/y.

pi

const float pi = 3.14159265358979323846;

Ratio of a circle's circumference to its diameter.

e

const float e = 2.71828182845904523536;

Base of the natural logarithm.