You can use an expression any place where a numeric value is expected. Expressions are made up of variables, explicit numbers, and a typical set of operators and parentheses with normal precedence rules. All variables, numbers, and results of mathematical expressions are represented internally with double precision floating-point numbers.
In APL, operand values are often used as logical, or Boolean, values. These values include the arguments of the If command, the operands of the And operator, and the argument of the Not( ) function. Boolean values treat the value of a number as either True or False. The floating-point value of the number is first truncated to an integer. If the resulting value is 0, it is considered False, and if the value is not 0, it is considered True. Whenever APL generates a Boolean value, a value of 1.0 is generated for True and 0.0 for False.
APL uses the unary operators included in the following table.
Operator | Description |
- | Numeric negation. |
NOT | Logical negation; result is 1 if operand is 0, otherwise 0. |
Binary operators combine a subexpression on the left with a subexpression on the right according to normal rules of precedence. Logical operators (=, AND, and so on) produce a value of 1 for True and 0 for False. APL uses the binary operators included in the following table.
Operator | Description |
+ | Add |
- | Subtract |
* | Multiply |
/ | Floating division |
IDIV | Integer division |
IREM, % | Integer remainder (modulus) |
& | Bitwise AND |
| | Bitwise OR |
XOR, ^ | Bitwise exclusive OR |
= | Equality |
!= | Inequality |
< | Less than |
<= | Less than or equal |
> | Greater than |
>= | Greater than or equal |
AND, && | Logical AND (True if both operands are True) |
OR, || | Logical OR (True if either or both operands are True) |