Arithmetic operator

The arithmetic operators of NWScript perform basic arithmetic on integers and floating point numbers. They consist of,   (unary),   (binary),  ,  , and.

Several of these operators tend to be readily recognizable, as they correspond well to standard arithmetic notation. That is,  performs addition,   in front of a number performs negation (converting positive to negative and vice versa),   between two numbers subtracts the second from the first, and   between two numbers divides the first by the second. (In this context, "number" can be an explicit number, a variable or function with a numeric value, or an expression that evaluates to a number.) Of the remaining arithmetic operators,  performs multiplication, while   is the modulus operator, which produces the remainder when the integer to its left is divided by the one to its right (unlike the other arithmetic operators, modulus is only defined for integers).

Aside from the modulus operator, NWScript allows arithmetic operators to operate on a mix of integers and floating point numbers. The result will be an integer if only integers are involved, and a floating point number otherwise. This is most significant with regards to the division operator, as integer division drops the remainder, while floating point division is carried out to as many decimal places as can be represented.

The priorities of the arithmetic operators follow the standard order of operations, with multiplication, division, and modulus performed before addition and subtraction. Within these two categories, operations are performed left-to-right.