FP built-in functions

Language reference ›› Floating point ››
Parent Previous Next

Note: In all function calls, arguments are always converted to the REAL type before to call the function and result is always of type REAL.

There is exceptions: SQR() and POW(), see below.


<angle> represents an angle expressed in radians.


ARCCOS(x)

This function returns the inverse cosine of <x>, in radians.


ARCSIN(x)

This function returns the inverse sine of <x>, in radians.


ARCTAN(x)

This function returns the inverse tangent of <x>, in radians.


COS(angle)

This function returns the cosine of <angle>.


EXP(x)

This function returns the value of e raised to the power of <x> (eX), where e is the base of the natural logarithms.


LN(x)

This function returns the natural logarithm of <x> (LN(e) = 1) .


POW(a, b)

This function returns <a> raised to <b> (ab).

if <b> = 0 the result is 1.

if <a> = 0 and <b> > 0 the result is 0.

The result is of type REAL, except: if both arguments are integer expressions the result is of the same type as the greatest precision argument.

If one of the argument is of type float, POW() is implemented as Y = eb.LN(a), if <a> is less or equal to zero, a run-time FP invalid operation error flag is set (FP_IOP).

Else (both are of type integer) POW() is implemented by a special fast integer routine that takes only unsigned values - The exponent is always 8-bit.

If both <a> and <b> are zero, a run-time FP invalid operation error flag is set (FP_IOP).


ROUND(x)

This function rounds a REAL or SINGLE value to an integer value.

It returns a LONGINT value that is the value of <x> rounded to the nearest whole number.

If <x> is exactly halfway between two whole numbers, the result is always the even number. This method of rounding is often called "Banker's Rounding".

If the rounded value of <x> is not within the LONGINT range, the function returns the maximum value (according to the sign) and a run-time FP integer overflow error flag is set (FP_IOV).

In the current implementation there is no support to return an INT64.


SIN(angle)

This function returns the sine of <angle>.


SQR(x)

This function returns the square of <x> (x²).

As an exception to the general rule, since SQR(x) is implemented as x*x, the argument may be of any type, integer or FP and the result is of the same type as the argument (Except for FP expressions, where the result is always of type REAL). Warning: overflow may occur since <x> is not converted; if a wider value is expected, cast <x> to a wider type.


SQRT(x)

This function returns the square root of <x>.

If <x> <= 0, a runtime FP invalid operation error flag is set (FP_IOP).


TAN(angle)

This function returns the tangent of <angle>. TAN(X) = SIN(X) / COS(X).


TRUNC(x)

This function truncates a real REAL or SINGLE value to an integer-type value.

It returns a LONGINT value that is the value of <x> rounded toward zero.

If the truncated value of <x> is not within the LONGINT range, the function returns the maximum value (according to the sign of <x>) and a run-time FP integer overflow error flag is set (FP_IOV).

In the current implementation there is no support to return an INT64.