## AQL - operators and types (Version 4_7h)

### Arithmetic operators `+' `-' `*' `/'

The table shows which combinations of value types are allowed for arithmetic operators.

| Int | Float | Object | String | Date Type | Boolean
--- | --- | --- | --- | --- | --- | ---
Int | * | O(1) | - | - | - | -
Float | O(1) | * | - | - | - | -
Object | - | - | - | - | - | -
String | - | - | - | - | - | -
Date Type | - | - | - | - | -(2) | -
Boolean | - | - | - | - | - | -

Value type combinations showing a '-' will raise error code 896.

- (1) - Integers are treated as Floats in mixed expressions.
- (2) Special date-functions to provide operations on date/time values.

### Unary minus operator -

Only numeric value-types (i.e. Int, Float) are allowed to be negated in this way.

### Modulo operator %

Both sides of the modulo expression have to be integers. Other value types will raise error code 897.

The modulo operator can be written as an infix operator as :
`x % y`
or as a function :
`modulo (x, y)
mod (x, y)`

All versions are evaluated in the same way.

### Comparison operators `==' `!=' `>' `<' `>=' `<=' (and 'like')

The table shows which combinations of value types are allowed for comparisons.

| Int | Float | Object | String | Date Type | Boolean
--- | --- | --- | --- | --- | --- | ---
Int | * | O(1) | - | - | - | O(5,6)
Float | O(1) | * | - | - | - | O(6,7)
Object | - | - | *(4) | O(2,3) | - | O(6,7)
String | - | - | O(2,3) | *(3) | - | O(6,7)
Date Type | - | - | - | - | * | O(6,7)
Boolean | O(5,6) | O(6,7) | O(6,7) | O(6,7) | O(6,7) | *(6)

Value type combinations showing a '-' will raise error code 884.

- (1) - integers are treated as floats.
- (2) - The object's name is compared to the text value.
- (3) - The operator like is allowed for comparisons involving string-types to perform wildcard matching.
  Possible wildcards are '*' which matches any number of any characters, and '?' which matches any one character.
- (4) - Only '=' and '!=' operators are allowed, when two Object values are compared to each other, otherwise error code 886 is raised.
- (5) - Integers are converted to Booleans - zero = FALSE, non-zero is TRUE. A NULL integer value is FALSE.
- (6) - Only '=' and '!=' operators are allowed, when a comparison involves a boolean value, otherwise error code 885 is raised.
- (7) - Comparison between a Boolean and a non-boolean value (Float/Object/String/DateType) :
  Any non-boolean value is said to be TRUE if a value exists, a NULL-value is treated as FALSE.

The value type of the comparison itself is Boolean. Therefore expressions such as 'not ((val1 = val2) = false)' are legal.

### Boolean operators `and' `or' `xor'

Rules (4) and (6) about comparison operators apply also to boolean operators. The operator's result is itself an expression returning a boolean value.