HAL/S typically supports the following set of built-in functions. Minor variations may arise between implementations.
ARITHMETIC FUNCTIONS
arguments may be INTEGER or SCALAR types
in functions with one argument, result type matches argument type (except as specifically noted)
in functions with two arguments, unless specifically specified, result type is scalar if either or both arguments are scalar; otherwise the result type is integer
arrayed arguments cause multiple invocations of the function, one for each array element - arrayness of arrayed arguments must match
Name, Arguments Comments
ABS(α) | α |
CEILING(α) smallest integer ≥α
DIV(α,β) integer division α/β (arguments rounded to integers) FLOOR (α) largest integer ≤α
MIDVAL(α,β,γ) the value of the argument which is algebraically between the other two. If two or more arguments are equal, the multiple value is returned. Result is always scalar. MOD(α,β) α MOD β
ODD(α) TRUE 1 if α odd FALSE 0 if α even
⎤
⎥ ⎯ result is BOOLEAN
⎦
REMAINDER(α,β) signed remainder of integer division α/β (argument rounded to integer)
ROUND(α) nearest integer to α SIGN(α) +1 α ≥ 0
-1 α < 0 SIGNUM(α) +1 α > 0
0 α = 0 -1 α < 0
ALGEBRAIC FUNCTIONS
• arguments may be integer or scalar types -- conversion to scalar occurs with integer arguments
• result type is scalar
• arrayed arguments cause multiple invocations of the function, one for each array element
• angular values are supplied or delivered in radians
Name, Arguments Comments
ARCCOS(α) cos -1α, | α| < 1 ARCCOSH(α) cosh -1α, ≥1 ARCSIN(α) sin -1α, | α| < 1 ARCSINH(α) sinh-1α
ARCTAN2(α,β) -π< tan-1 (α/β) < π Proper Quadrant if:
α= k sin θ β= k cos θ ⎫ ⎬ k > 0 ⎭ ARCTAN(α) tan-1α ARCTANH(α) tanh-1α, | α | < 1 COS(α) cos α COSH(α) cosh α EXP(α) eα LOG(α) logeα, α > 0 SIN(α) sin α SINH(α) sinh α SQRT(α) , α≥ 0 TAN(α) tan α TANH(α) tanh α α
VECTOR-MATRIX FUNCTIONS
• arguments are vector or matrix types as indicated • result types are as implied by mathematical operation
• arrayed arguments cause multiple invocation of the function, one for each array element
Name, Arguments Comments
ABVAL(α) length of vector α.
DET(α) determinant of square matrix α.
INVERSE(α) inverse of a nonsingular square matrix α. TRACE(α) sum of diagonal elements of square matrix α. TRANSPOSE(α) transpose of matrix α.
UNIT(α) unit vector in same direction as vector α.
MISCELLANEOUS FUNCTIONS
• arguments are as indicated; if none are indicated the function has no arguments • result type is as indicated
Name, Arguments Result Type Comments
CLOCKTIME scalar returns time of day
DATE integer returns date (implementation dependent format) ERRGRP integer returns group number of last error detected, or
zero
ERRNUM integer returns number of last error detected, or zero PRIO integer returns priority of process calling function RANDOM scalar returns random number from rectangular
distribution over range 0-1
RANDOMG scalar scalar returns random number from Gaussian distribution mean zero, variance one.
RUNTIME scalar scalar returns Real Time Executive clock time (Section 8.)
NEXTIME (<label>) scalar <label> is the name of a program or task. The value returned is determined as follows: a) If the specified process was scheduled with the REPEAT ENTRY option and has begun at least one cycle of execution, then the value is the time the next cycle will begin.
b) If the specified process was scheduled with the IN or AT phrase, and has not yet begun execution, then the value is the time it will begin execution.
c) Otherwise, the value is equal to the current time (RUNTIME function).
MISCELLANEOUS FUNCTIONS (Cont’d)
SHL(α,β) Same as α α may be integer or scalar type. β may be integer or scalar type.
If α is integer type, the result is an integer whose internal binary representation is that of α shifted left by β bit locations. The signed nature of the integer α is taken into account in an
implementation dependent manner which depends upon the number system and word size of the target computer.
Scalar types will be converted to integer types prior to shifting. If β is a literal or constant, then it is illegal for it to be outside the range (1,63). Otherwise, only the 6 right-most bits of the value are used, restricting the range to (0,63).
Arrayed arguments produce multiple invocations of the function, one for each array element- arrayness of arrayed arguments must match. SHR(α,β) Same as α α may be integer or scalar type. β must be
integer type.
Results are as defined for the SHL function except that all shifting occurs to the right. The SHR is an arithmetic shift (sign bit is
propagated).
Arrayed arguments produce multiple invocations of the function, one for each array element - arrayness of arrayed arguments must match.
CHARACTER FUNCTIONS
• first argument is character type - second argument is as indicated (any argument indicated as character type may also be integer or scalar, whereupon conversion to character type is implicitly assumed)
• result type is as indicated
• arrayed arguments produce multiple invocations of the function, one for each array element - arraynesses of arrayed arguments must match
Name, Arguments Result Type Comments
INDEX(α,β) integer β is character type - if string β appears in string α , index pointing to the first character of β is
returned; otherwise zero is returned LENGTH(α) integer returns length of character string
LJUST(α,β) character β is integer type - string α is expanded to length β by padding on the right with blanks. β > length (α) RJUST(α,β) character β is integer type - string α is expanded to length β
by padding on the left with blanks. β > length (α) TRIM(α) character leading and trailing blanks are stripped from α