Arithmetic Functions and Methods

Table 19-7 summarizes the standard arithmetic and trigonometric operations that are provided in GPL.  As a convenience during editing, the operations within the first table are provided as methods of the Math Class.  This allows programmers to display a pick list of the Math methods and easily see all of operations that are available.  The second table documents functions that are not part of the Math Class.  These functions are provided in this manner for compatibility with other Basic Languages.

As is standard in GPL, conversions between different arithmetic types, e.g. Integer, Single, Double, are automatically performed as required.  So, it is not necessary to have different variations on these methods and functions to deal with the different possible mixes of input parameter data types.  Also, these methods and functions generally produce results that are formatted as Double’s.  Results are automatically converted to smaller data types as necessary, e.g. Double -> Integer, and will not generate an error so long as numeric overflow does not occur.

For more information on these methods and functions, please see the Reference Documentation section.

Table 19-7: Arithmetic and Trigonometric Operations in GPL

Math Methods Description

Math.Abs(expression)

Returns the absolute value of any arithmetic expression.

Math.Acos(cosine)

Returns the angle that corresponds to a specified cosine value.

Math.Asin(sine)

Returns the angle that corresponds to a specified sine value.

Math.Atan(tangent)

Returns the angle that corresponds to a specified tangent value.

Math.Atan2(sine_factor, cosine_factor)

Returns the angle that corresponds to the quotient of two values.

Math.Ceiling(value)

Returns the smallest integer number that is greater than or equal to a value.

Math.Cos(angle)

Returns the cosine of a specified angle.

Math.Cosh(angle)

Returns the hyperbolic cosine of a specified angle.

Math.E

Returns the natural logarithmic base constant.

Math.Exp(exponent)

Returns the natural logarithmic constant, e, raised to a specified power.

Math.Floor(value)

Returns the largest integer number that is less than or equal to a value.

Math.Log(value)

Returns the natural logarithm (base-e logarithm) of a specified value.

Math.Log10(value)

Returns the base-10 logarithm of a specified value.

Math.Max(value_1, value_2)

Returns the larger of two values.

Math.Min(value_1, value_2)

Returns the smaller of two values.

Math.PI

Returns the constant π.

Math.Pow(base, exponent)

Returns a specified base value raised to a specified power.

Math.Sign(value)

Returns a number that indicates the sign of a specified value.

Math.Sin(angle)

Returns the sine of a specified angle.

Math.Sinh(angle)

Returns the hyperbolic sine of a specified angle.

Math.Sqrt(value)

Returns the square root of a value.

Math.Tan(angle)

Returns the tangent of a specified angle.

Math.Tanh(angle)

Returns the hyperbolic tangent of a specified angle.

 

Built-in Functions Description

Fix(number)

Returns the integer portion of any numeric type by truncating towards zero.

Int(number)

Returns the integer portion of any numeric type by truncating towards negative infinity.

Rnd(seed)

Returns a pseudo random number.