Summary:
See also: Built-in Functions
The Math class provides mathematical functions.
This API is provided as a Dynamic C Extension library; it is part of the standard package.
To use this extension, you must import the util package in your program:
IMPORT util
The Math class is a provides an interface for mathematical functions.
util.Math
Class Methods | |
Name | Description |
sqrt | This function computes the square root of its argument. |
pow | This function computes the value of x raised to the power y. |
exp | This function computes the base- e exponential of x. |
srand | This function intializes the pseudo-random number generator. |
rand | This function returns a pseudo-random number. |
sin | This function computes the sine of their argument x, measured in radians. |
cos | This function computes the cosine of their argument x, measured in radians. |
tan | This function computes the tangent of their argument x, measured in radians. |
asin | This function computes the arc sine of their argument x, measured in radians. |
acos | This function computes the arc cosine of their argument x, measured in radians. |
atan | This function computes the arc tangent of their argument x, measured in radians. |
log | This function computes the natural logarithm of the argument x. |
toDegrees | Converts an angle measured in radians to an equivalent angle measured in degrees. |
toRadians | Converts an angle measured in degrees to an equivalent angle measured in radians. |
pi | This function returns the FLOAT value of PI. |
Returns the square root of the argument provided.
CALL util.Math.sqrt( val FLOAT ) RETURNING rv FLOAT
This function computes the value of x raised to the power y.
CALL util.Math.pow( x FLOAT, y FLOAT ) RETURNING rv FLOAT
If x is negative, the caller should ensure that y is an integer value.
This function computes the base-e exponential of the value passed as parameter.
CALL util.Math.exp( val FLOAT ) RETURNING rv FLOAT
This function initializes the pseudo-random numbers generator.
CALL util.Math.srand()
The srand() function initializes the pseudo-random numbers generator. It must be called before subsequent calls to the rand() function. If you do not call this function, the rand() function will generate the same sequence of numbers for every program execution.
This function returns a positive pseudo-random number.
CALL util.Math.rand( max INTEGER ) RETURNING rv INTEGER
The srand() function must be called before subsequent calls to the rand() function. If you do not call the srand() function, the rand() function will generate the same sequence of numbers for every program execution.
Note that the maximum random number returned by the rand() function is platform dependent. On most platforms, the max will be 32767. As a general rule, you should pass a number between 0 and 32767 to the rand() function.
The rand() function returns zero if the argument is lower or equal to 0.
This function computes the sine of the passed value, measured in radians.
CALL util.Math.sin( val FLOAT ) RETURNING rv FLOAT
This function computes the cosine of the passed value, measured in radians.
CALL util.Math.cos( val FLOAT ) RETURNING rv FLOAT
This function computes the tangent of the passed value, measured in radians.
CALL util.Math.tan( val FLOAT ) RETURNING rv FLOAT
This function computes the arc sine of the passed value, measured in radians.
CALL util.Math.asin( val FLOAT ) RETURNING rv FLOAT
This function computes the arc cosine of the passed value, measured in radians.
CALL util.Math.acos( val FLOAT ) RETURNING rv FLOAT
This function computes the arc tangent of the passed value, measured in radians.
CALL util.Math.atan( val FLOAT ) RETURNING rv FLOAT
This function computes the natural logarithm of the passed value.
CALL util.Math.log( val FLOAT ) RETURNING rv FLOAT
Converts an angle measured in radians to an approximately equivalent angle measured in degrees.
CALL util.Math.toDegrees( val FLOAT ) RETURNING rv FLOAT
Converts an angle measured in degrees to an approximately equivalent angle measured in radians.
CALL util.Math.toRadians( val FLOAT ) RETURNING rv FLOAT
This function returns the FLOAT value of PI.
CALL util.Math.pi() RETURNING rv FLOAT