[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4.2.2 Operations on Numbers

Function: int random ([int mod])
mod must be a positive integer; otherwise, E_INVARG is raised. An integer is chosen randomly from the range [1..mod] and returned. If mod is not provided, it defaults to the largest MOO integer, 2147483647.

Function: num min (num x, ...)
Function: num max (num x, ...)
These two functions return the smallest or largest of their arguments, respectively. All of the arguments must be numbers of the same kind (i.e., either integer or floating-point); otherwise E_TYPE is raised.

Function: num abs (num x)
Returns the absolute value of x. If x is negative, then the result is -x; otherwise, the result is x. The number x can be either integer or floating-point; the result is of the same kind.

Function: str floatstr (float x, int precision [, scientific])
Converts x into a string with more control than provided by either tostr() or toliteral(). Precision is the number of digits to appear to the right of the decimal point, capped at 4 more than the maximum available precision, a total of 19 on most machines; this makes it possible to avoid rounding errors if the resulting string is subsequently read back as a floating-point value. If scientific is false or not provided, the result is a string in the form "MMMMMMM.DDDDDD", preceded by a minus sign if and only if x is negative. If scientific is provided and true, the result is a string in the form "M.DDDDDDe+EEE", again preceded by a minus sign if and only if x is negative.

Function: float sqrt (float x)
Returns the square root of x. Raises E_INVARG if x is negative.

Function: float sin (float x)
Function: float cos (float x)
Function: float tan (float x)
Returns the sine, cosine, or tangent of x, respectively.

Function: float asin (float x)
Function: float acos (float x)
Returns the arc-sine or arc-cosine (inverse sine or cosine) of x, in the range [-pi/2..pi/2] or [0..pi], respectively. Raises E_INVARG if x is outside the range [-1.0..1.0].

Function: float atan (float y [, float x])
Returns the arc-tangent (inverse tangent) of y in the range [-pi/2..pi/2] if x is not provided, or of y/x in the range [-pi..pi] if x is provided.

Function: float sinh (float x)
Function: float cosh (float x)
Function: float tanh (float x)
Returns the hyperbolic sine, cosine, or tangent of x, respectively.

Function: float exp (float x)
Returns e raised to the power of x.

Function: float log (float x)
Function: float log10 (float x)
Returns the natural or base 10 logarithm of x. Raises E_INVARG if x is not positive.

Function: float ceil (float x)
Returns the smallest integer not less than x, as a floating-point number.

Function: float floor (float x)
Returns the largest integer not greater than x, as a floating-point number.

Function: float trunc (float x)
Returns the integer obtained by truncating x at the decimal point, as a floating-point number. For negative x, this is equivalent to ceil(); otherwise it is equivalent to floor().


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on September, 30 2008 using texi2html