bubblecode supports standard arithmetic and a library of built-in math functions.
Arithmetic operators
| Operator | Meaning | Example |
|---|---|---|
+ | Addition | 2 + 3 |
- | Subtraction | 10 - 4 |
* | Multiplication | 6 * 7 |
/ | Division | 20 / 4 |
mod | Modulo | 17 mod 5 |
^ | Exponent | 2 ^ 10 |
example.bubbleParentheses control evaluation order, just like in normal math.
Built-in math functions
| Function | Description |
|---|---|
abs(n) | Absolute value |
round(n) | Round to nearest integer |
floor(n) | Round down |
ceil(n) | Round up |
sqrt(n) | Square root |
min(...) | Smallest of the arguments |
max(...) | Largest of the arguments |
example.bubbleRandom numbers
The random(n) function returns a random integer between 1 and n (inclusive).
example.bubble