Skip to main content
Version: 2.4.6

Math

*​

Multiplication of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

+​

Addition of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

-​

Subtraction of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

/​

Division of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

abs​

Absolute value.

Type:

('a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)

acos​

Arc cosine. The argument must fall within the range [-1.0, 1.0]. Result is in radians and is between 0.0 and pi.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

asin​

Arc sine. The argument must fall within the range [-1.0, 1.0]. Result is in radians and is between -pi/2 and pi/2.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

atan​

Arc tangent. Result is in radians and is between -pi/2 and pi/2.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

bool_of_float​

Convert a float to a bool.

Type:

(float) -> bool

Arguments:

  • (unlabeled) (of type float)

bool_of_int​

Convert an int to a bool.

Type:

(int) -> bool

Arguments:

  • (unlabeled) (of type int)

ceil​

Round above to an integer value. ceil(x) returns the least integer whose value is greater than or equal to x. The result is returned as a float.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

cos​

Cosine. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

cosh​

Hyperbolic cosine. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

dB_of_lin​

Convert linear scale into decibels.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

exp​

Exponential.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

float​

Convert a number to a float.

Type:

('a) -> float where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)

float.is_infinite​

Return true if the floating point number is infinite.

Type:

(float) -> bool

Arguments:

  • (unlabeled) (of type float)

float.is_nan​

Return true if the floating point number is NaN.

Type:

(float) -> bool

Arguments:

  • (unlabeled) (of type float)

float.truncate​

Round a float to a given number of decimal digits. Mode can be "ceil" (round up), "floor" (round down), or "default" (round to nearest).

Type:

(?digits : int, ?mode : string, float) -> float

Arguments:

  • digits (of type int, which defaults to 0): Number of decimal digits to keep.
  • mode (of type string, which defaults to "default"): Rounding mode: "ceil", "floor", or "default".
  • (unlabeled) (of type float)

float_of_int​

Convert an int to a float.

Type:

(int) -> float

Arguments:

  • (unlabeled) (of type int)

floor​

Round below to an integer value. floor(x) returns the greatest integer whose value is less than or equal to x. The result is returned as a float.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

infinity​

Float representation of infinity.

Type:

float

int​

Convert a number to an integer.

Type:

('a, ?raise : bool) -> int where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • raise (of type bool, which defaults to false): Raise error.invalid if number is NaN or +/-infinity.

int_of_float​

Convert a float to a int.

Type:

(float) -> int

Arguments:

  • (unlabeled) (of type float)

lin_of_dB​

Convert decibels into linear scale.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

ln​

Natural logarithm.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

log10​

Base 10 logarithm.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

lsl​

Logical shift left.

Type:

(int, int) -> int

Arguments:

  • (unlabeled) (of type int): Number to shift.
  • (unlabeled) (of type int): Number of bits to shift.

lsr​

Logical shift right.

Type:

(int, int) -> int

Arguments:

  • (unlabeled) (of type int): Number to shift.
  • (unlabeled) (of type int): Number of bits to shift.

max​

Compute the maximum of two values.

Type:

('a, 'a) -> 'a where 'a is an orderable type

Arguments:

  • (unlabeled) (of type anything that is an orderable type)
  • (unlabeled) (of type anything that is an orderable type)

max_int​

Maximal representable integer.

Type:

int

min​

Compute the minimum of two values.

Type:

('a, 'a) -> 'a where 'a is an orderable type

Arguments:

  • (unlabeled) (of type anything that is an orderable type)
  • (unlabeled) (of type anything that is an orderable type)

min_int​

Minimal representable integer.

Type:

int

mod​

Remainder of division of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

nan​

A special floating-point value denoting the result of an undefined operation such as 0.0 /. 0.0. Stands for 'not a number'. Any floating-point operation with nan as argument returns nan as result. As for floating-point comparisons, ==, <, <=, > and >= return false and != returns true if one or both of their arguments is nan.

Type:

float

pow​

Exponentiation of numbers.

Type:

('a, 'a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)
  • (unlabeled) (of type anything that is a number type)

random.float​

Generate a random value between min (included) and max (excluded).

Type:

(?min : float, ?max : float) -> float

Arguments:

  • min (of type float, which defaults to 0.0)
  • max (of type float, which defaults to 1.0)

random.int​

Generate a random value between min (included) and max (excluded).

Type:

(?min : int, ?max : int) -> int

Arguments:

  • min (of type int, which defaults to -536870911)
  • max (of type int, which defaults to 536870912)

round​

Rounds x to the nearest integer with ties (fractional values of 0.5) rounded away from zero, regardless of the current rounding direction. If x is an integer, +0., -0., nan, or infinite, x itself is returned.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

sign​

Return 1. if the argument is positive and -1. otherwise.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

sin​

Sine. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

sinh​

Hyperbolic sine. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

sqrt​

Square root.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

tan​

Tangent. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

tanh​

Hyperbolic tangent. Argument is in radians.

Type:

(float) -> float

Arguments:

  • (unlabeled) (of type float)

~-​

Returns the opposite of its argument.

Type:

('a) -> 'a where 'a is a number type

Arguments:

  • (unlabeled) (of type anything that is a number type)