Arithmetic functions – VTech Precomputer Power Pad Plus User Manual

Page 56

Advertising
background image

52

ARITHMETIC FUNCTIONS

ABS (X)

This gives the absolute (positive) value of the argument. So ABS (-7)=7.

Example:

PRINT ABS (7-2*4)

press ENTER

1

SGN (X)

This function will give the value of +1 if X is positive, 0 if X is zero, and -1 if X is negative.
So SGN(4.3)=1; SGN(0)=0; SGN(-276)=-1

Example:

A=6

press ENTER

PRINT SGN (A); SGN (A-A)

press ENTER

1 0

INT (X)

This converts numbers which are not whole into the largest whole number below the
argument. So INT (5.9)=5; also INT (-5.9)=-6. Note that with negative arguments, the
absolute value of the result returned by INT will be greater than that of the number.

Example:

PRINT INT (-6.7)

press ENTER

-7

RND (X)

This will produce a random number between 1 and X if X is a positive number.

Advertising