Smudge

The modern and fun way to program.

View the Project on GitHub

The Smudge Programming Language - box std.math

std.math is just an interface to the C++ math library <cmath> plus a couple of function to generate random numbers. So, see also the original C++ docs on cplusplus.com).

Var NAN

Contains the floating-point Not A Number value. Note that NAN == NAN and std.cast::same(NAN, NAN) return false: use is_nan(x).

Var INF

Contains the floating-point Infinity value.

Var E

The Euler’s number stored in a float.

Var PI

The PI constant stored in a float.

Function rand ()

Generates and returns a random float between 0 and 1 (1 excluded).

Function rand_int (min, max)

Generates and returns a random integer between min and max (max excluded), or null if either min or max is not an integer.

Function deg (r)

Converts the angle r (float or integer) expressed in radians to degrees. Returns the new float, ornull, if r` is an invalid parameter.

Function rad (d)

Converts the angle r (float or integer) expressed in degrees to radians. Returns the new float, ornull, if r` is an invalid parameter.

Function frexp (x)

Returns a tuple containing the values of significand and exp that make true the following equation:
x = significand * 2exp

Function hypot (a, b)

Returns the length of the hypotenuse given the catheti (i.e. legs) a and b (integers or floats) or null if the parameters are invalid.

Other functions

Each of the next functions accept as parameter one or more floats (or integers) and return a float, or null if the parameters are invalid. Angles are expressed in radians (both input and output values). Use deg() and rad() for angle conversions.