Vikari Language Documentation


Available since:  v0.1.1.

Arithmetic Operators

Vikari supports the following binary arithmetic operators:

Operator NameSymbolFunction
Add+Add two numbers.
Subtract-Subtract the second number from the first.
Multiply*Multiply two numbers.
Left Divide\Divide the left number by the right.
Right Divide/Divide the right number by the left.

Promotion of Numeric Types in Arithmetic Expressions

These enable expressions to apply the standard arithmetic operations against any of the numeric datatypes. Number types are automatically promoted to the largest necessary type. So if a Float and an Integer are added (i.e. 5 + 2.7) the result will be 7.7 as a Float value.

Examples

The following demonstrates use of the arithmetic operators.

~:The add operator adds two numbers together.:~
result << 5 + 2.7

~:The subtract operator subtracts the second number from the first.:~
result << 5 - 2.7

~:The multiply operator * multiplies two numbers together.:~
result << 5 * 2.7

~:The left divide operator divides the first number by the second.:~
result << 5 / 2.7

~:The right divide operator divides the second number by the first.:~
result << 5 \ 2.7