Numeric Functions

< Show List

Functions that return numeric values (although not necessarily ones that require numeric arguments).


sgn(VAL)

Returns the sign of the parameter value. Returns 1 if the value is greater than zero , zero if equal to zero. -1 if negative.


abs(x)

Returns the absolute value of x.


int(x)

Returns the integer value of x. Truncates toward negative infinity. The absolute value of x must be less than 2^31-1. The usage int(x, 0) truncates towards zero.


floor(x)

Returns the integer value of x. Truncates toward negative infinity.


sqr(x)

Returns the square root of x.


log(x)

Returns the natural logarithm of x.


log10(x)

Returns the logarithm base 10 of x.


exp(x)

Returns e^x. e=2.7182818...


sin(x)

cos(x)

atn(x)

Trigonometric functions: sin, cosine and arctangent.


pi

Returns pi, 3.141592653589793...


rnd ( EXPR )

Returns an integer pseudo-random number between 0 and int(EXPR)-1 inclusive. If EXPR is 1, then returns a rational number between 0 (inclusive) and 1. If EXPR is negative then EXPR seeds the random number generator.


randomize EXPR

Seeds the random number generator with the integer EXPR. The pseudo-random number generator should return the same sequence when seeded with the same start value. The actual sequence may be system dependant.


len( STRINGEXPR )

Returns the length of the string STRINGEXPR.

len( TYPED-VAR )

Returns the length, in bytes, of a typed record (one created by DIM AS NEW).


val( STRINGEXPR | EXPR )

Value of the expression contained in a STRINGEXPR or EXPR. STRINGEXPR may be a string literal, variable, function, or expression.

For example, VAL("1 + sqr(4)") yields 3.


asc( STRINGEXPR )

Returns the ascii code for the first character of STRINGEXPR. A null string returns zero.


instr(a$, b$ { , VAL } )

Returns the position of the substring b$ in the string a$ or returns a zero if b$ is not a substring. VAL is an optional starting position in a$.


ubound( VAR [, EXPR ] )

If VAR is a dimensioned array, returns the maximum legal subscript of the first dimension of that array, else returns 0. Use EXPR to return other dimensions.


isarray( VAR )

If VAR is a dimensioned array, returns the number of dimensions, otherwise returns 0.


fgetbyte( FILENUM )

Reads one byte from the open file specified by FILENUM and returns an unsigned numeric value [0..255].


eof(FILENUM)

Returns true if the the last INPUT statement, INPUT$ or FGETBYTE function call which referenced the text file specified by FILENUM tried to read past the end of file. (Note that reading the last line of a file will not read past the eof mark. A subsequent read is needed to set the EOF flag to true. Reading past the end-of-file will not report an error.)


pop

POP function (see also POP statement). Pops one variable value off the stack and returns that value (string or numeric).

(POP can be used as either a statement (with a parameter) or a function (no parameter). Note that the POP function, unlike the POP statement, does not restore the value of the variable pushed, but only returns the pushed value. This use of the POP statement is different from the Applesoft usage.)


peek( ADDR { , SIZE_VAL } )

Returns the value of the byte in memory at address ADDR. If SIZE_VAL is 2 or 4, returns the value of the 16-bit or 32-bit word respectively (if correctly aligned). If SIZE_VAL is 8, returns the value of the numeric variable located at ADDR. (peek(varptr(x),8) == x)


varptr( VAR | STRINGVAR )

Returns the memory address of a variable.


erl

Returns the line number of the last error. Zero if the error was in immediate mode. The variable errorstatus$ gives the error type.


timer

Returns a numeric value of elapsed of seconds from the computer's internal clock.