Please enable JavaScript to view this site.

A-Shell Reference

Updated February 2023; see History

These functions all return numeric values, although some may operate on string arguments.

Function

Description

ABS(x)

Returns absolute value of x.

EXP(x)

Returns the constant e (2.718218285) raised to the power x.

FACT(x)

Returns the factorial of x.

FIX(x)

Returns the integer part of the floating point value x. See History.

INT(x)

Returns the largest integer less than or equal to x. FIX(x) and INT(x) are same for positive numbers, but differ for negative numbers. See History.

LEN(a$)

Returns length of string A$. Note that if a$ is actually a variable of type x, the returned length will always be the physical mapped size of the variable. Otherwise, for strings (type S), the returned length will be determined by the first null byte or the physical mapped length, whichever is smaller.

LOG(x)

Returns the natural (base e) log of x.  

LOG10(x)

Returns the decimal logarithm of x.

NUMEXPR

See in String Functions.

RND(x)

Returns a random number.

RND2()

Enhanced version of RND(x).

SRND2(x...)

Initializes the RND2() generator.

SGN(x)

Returns the sign of x: -1 if x < 0, 0 if x = 0, 1 if x > 0.

SQR(x)

Returns the square root of x.

VAL(x)

See in String Functions.

 

History

2023 February, A-Shell 6.5.1724:  INT() and FIX() update. When FPROUND is not set, these functions now apply a fudge factor of .0000005 (one tenth of the standard FPROUND factor). This minimizes the problem illustrated whereby an expression like INT(140.4*100) might result in 14039 rather than 14040. The discrepancy is caused by the inherent imprecision of binary floating point representation of decimal fractions—e.g., 14039.999999975 instead of 14040.0).

There are various other ways to deal with this issue, including setting the FPROUND option, but the issue continues to catch programmers by surprise; this automatic adjustment should minimize that problem. But note that it only works for numbers up to about 8 significant digits, after which the tiny fudge factor becomes too small to matter. If you regularly work with larger numbers and aren't explicitly dealing with rounding within the application, you may want to set your rounding factor somewhat higher. See "Rounding of Floating Point Variables" in the A-Shell reference for more details..

2016 July, A-Shell 6.3.1517:  Add second random number generator, RND2 and SRND2.

Subtopics

Random Number Generators