API / JavaScript / Js / Math

Math

Provide utilities for JS Math.

let _E: float;

Euler's number.

let _LN2: float;

Natural logarithm of 2.

let _LN10: float;

Natural logarithm of 10.

let _LOG2E: float;

Base 2 logarithm of E.

let _LOG10E: float;

Base 10 logarithm of E.

let _PI: float;

Pi - ratio of the circumference and diameter of a circle.

let _SQRT1_2: float;

Square root of 1/2.

let _SQRT2: float;

Square root of 2.

let abs_int: int => int;

Absolute value.

let abs_float: float => float;

Absolute value.

let acos: float => float;

Arccosine in radians, can return NaN.

let acosh: float => float;

Hyperbolic arccosine in radians, can return NaN.

let asin: float => float;

Arcsine in radians, can return NaN.

let asinh: float => float;

Hyperbolic arcsine in radians.

let atan: float => float;

Arctangent in radians.

let atanh: float => float;

Hyperbolic arctangent in radians, can return NaN.

let atan2: (~y: float, ~x: float, unit) => float;

Arctangent of the quotient of x and y, mostly... this one's a bit weird.

let cbrt: float => float;

Cube root, can return NaN.

let unsafe_ceil_int: float => int;

May return values not representable by int.

let unsafe_ceil: float => int;
let ceil_int: float => int;

Smallest int greater than or equal to the argument.

let ceil: float => int;
let ceil_float: float => float;
let clz32: int => int;

Number of leading zero bits of the argument's 32 bit int representation.

let cos: float => float;

Cosine in radians.

let cosh: float => float;

Hyperbolic cosine in radians.

let exp: float => float;

Natural exponentional.

let expm1: float => float;

Natural exponential minus 1.

let unsafe_floor_int: float => int;

May return values not representable by int.

let unsafe_floor: float => int;
let floor_int: float => int;

Largest int greater than or equal to the arugment.

let floor: float => int;
let floor_float: float => float;
let fround: float => float;

Round to nearest single precision float.

let hypot: (float, float) => float;

Pythagorean equation.

let hypotMany: array(float) => float;

Generalized pythagorean equation.

let imul: (int, int) => int;

32-bit integer multiplication.

let log: float => float;

Natural logarithm, can return NaN.

let log1p: float => float;

Natural logarithm of 1 + the argument, can return NaN.

let log10: float => float;

Base 10 logarithm, can return NaN.

let log2: float => float;

Base 2 logarithm, can return NaN.

let max_int: (int, int) => int;

Max value.

let maxMany_int: array(int) => int;

Max value.

let max_float: (float, float) => float;

Max value.

let maxMany_float: array(float) => float;

Max value.

let min_int: (int, int) => int;

Min value.

let minMany_int: array(int) => int;

Min value.

let min_float: (float, float) => float;

Min value.

let minMany_float: array(float) => float;

Min value.

let pow_int: (~base: int, ~exp: int) => int;

Base to the power of the exponent.

let pow_float: (~base: float, ~exp: float) => float;

Base to the power of the exponent.

let random: unit => float;

Random number in [0,1).

let random_int: (int, int) => int;

Random number in [min,max).

let unsafe_round: float => int;

Rounds to nearest integer, returns a value not representable as int if NaN.

let round: float => float;

Rounds to nearest integer.

let sign_int: int => int;

The sign of the argument, 1, -1 or 0.

let sign_float: float => float;

The sign of the argument, 1, -1, 0, -0 or NaN.

let sin: float => float;

Sine in radians.

let sinh: float => float;

Hyperbolic sine in radians.

let sqrt: float => float;

Square root, can return NaN.

let tan: float => float;

Tangent in radians.

let tanh: float => float;

Hyperbolic tangent in radians.

let unsafe_trunc: float => int;

Truncate, ie. remove fractional digits, returns a value not representable as int if NaN.

let trunc: float => float;

Truncate, ie. remove fractional digits, returns a value not representable as int if NaN