Skip to content

Operators

Louis Lefevre edited this page Jun 9, 2020 · 1 revision

What are operators:

An operator is a symbol which is used to perform a mathematical operations on values. This is most common with numbers, such as in the case of adding two numbers together, the operator would be the plus symbol. Here is an example:

10 + 20
20 - 15
50 * 50
90 / 30

In each of the above examples, the operator is the symbol in the middle: '+', '-', '*', and '/'.

Can each operator be used with any data type?

Most operators can only be used with numbers (integers and doubles), though there are some exceptions. To view a full list of compatible data types, refer to the table in the next section.

What do each of the operators do?

This table lists each of the operators available in Onyx, describing their functionality with examples.

Note that the "Data Types" column is used to show which data types are compatible with each operator. So for example, the plus operator can be used with integers, doubles, and strings, but cannot be used with booleans.

Name Symbol Data Types Example Description
Plus + Integer Double String 10 + 5 Adds the values of two numbers together
Minus - Integer Double 10 - 5 Subtracts a value from another
Multiply * Integer Double 10 * 5 Multiplies a value by another
Divide / Integer Double 10 / 5 Divides a value by another
Modulo % Integer Double 10 % 5 Returns the remainder of division
Power ^ Integer Double 10 ^ 5 Multiplies the first value a certain amount of times, as specified by the second value.
Plus-Assignment += Integer Double String var += 10 Adds the value to the variable
Minus-Assignment -= Integer Double var -= 10 Subtracts the value from the variable
Multiply-Assignment *= Integer Double var *= 10 Multiplies the value by the variable
Divide-Assignment /= Integer Double var /= 10 Divides the value by the variable
Modulo-Assignment %= Integer Double var %= 10 Returns the remainder of division between the value and the variable.
Power-Assignment ^= Integer Double var ^= 10 Multiplies the variable a certain amount of times, as specified by the value.

Table of Contents

General Information

User Guide

Developer Guide

Clone this wiki locally