Built-in arithmetic functions – BrightSign HD2000 BrightScript Reference Guide User Manual

Page 27

Advertising
background image

27

Built-in Arithmetic Functions

BrightScript offers a wide variety of intrinsic ("built-in") functions for performing arithmetic and special
operations.

All the common math functions use type rotFLOAT (not Double).

Trig functions use or return radians, not degrees.

For all the functions, the argument must be enclosed in parentheses. The argument may be a numeric variable,
expression or constant.

Functions described in this section:

ABS

COS

INT

SGN

ERR

ATN

CSNG

LOG

SIN

ERL

CDBL

EXP

RANDOM

SQR

FIX

RND

TAN

ABS (x)

Returns the absolute value of the argument.

ATN (x)

Returns the arctangent (in radians) of the argument; that is, ATN(X) returns "the angle whose tangent is X".
To get arctangent in degrees, multiply ATN(X) by 57.29578. Returns a double-precision representation of
the argument.

COS (x)

Returns the cosine of the argument (argument must be in radians). To obtain the cosine of X when X is in
degrees, use CGS(X*.01745329).

CSNG (x)

Returns a single-precision float representation of the argument. When the argument is a double-precision
value, it is returned as six significant digits with "4/5 rounding" in the least significant digit. So
CSNG(.6666666666666667) is returned as .666667; CSNG(.3333333333333333) is returned as .333333.

EXP (x)

Returns the "natural exponential" of X, that is, ex. This is the inverse of the LOG function, so
X=EXP(LOG(X)).

FIX (x)

Returns a truncated representation of the argument. All digits to the right of the decimal point are simply
chopped off, so the resultant value is an integer. For non-negative X, FIX(X)=lNT(X). For negative values of
X, FIX(X)=INT(X)+1. For example, FIX(2.2) returns 2, and FIX(-2.2) returns -2.

INT(x)

Returns an integer representation of the argument, using the largest whole number that is not greater than the
argument.. INT(2.5) returns 2; INT(-2.5) returns -3; and INT(1000101.23) returns 10000101.

Advertising
This manual is related to the following products: