Skip to content

Number

  • A Number is stored as a 32-bit float.
  • Generally, no distinction is made between integers and floating-point values, except in some cases where integers are strictly required.

Arithmetic

Operator Description
+ Addition
- Subtraction
* Multiply
/ Divide

Info

Number can be added to String to produce a new String:

1 + " Malaysia" is equal to "1 Malaysia"

Warning

Division by zero will result in an error.

Example 1

1
2
3
4
println 1 + 3 / 5;                          // 1.6
println  4 - 3 * (4 - 2 * (6 - 3)) / 3;     // 6
println 0.99999 / 0.99999;                  // 1
println 1 / 0;                              // Division by zero error

Logical comparisons

Operator Description
== Equal to
!= Not equal to
> Greater
>= Greater or equal to
< Less than
<= Less or equal to

Info

Logical comparisons return a Boolean.

Example 2

1
2
3
4
5
println  1 == 1.0;      // true
println 2.999999  < 3;  // true
println 2.9999999 < 3;  // false
println 2.9999999 <= 3; // true
println 2.9999999 > 3;  // false

Question

  • From the example above, why is 2.999999 < 3 equal to true

    but

    2.9999999 < 3 equal to false?

  • What does this demonstrate about Ari's floating-point numbers?

Answer

Ari's Number is stored as a 32-bit float, so its precision is limited.


Built-in functions

to_string

to_string(Number)String


power

power(base: Number, power: Number)Number


log

log(base: Number, value: Number)Number

Warning

  • The program halts with this error if the log value is invalid (NaN or Inf):

Placeholder


modulo

modulo(value: Number, modulee: Number)Number

Warning


absolute

absolute(Number)Number

  • Returns the absolute value of the input

floor

floor(Number)Number

  • Returns the greatest integer less than or equal to the input

ceiling

ceiling(Number)Number

  • Returns the least integer greater than or equal to the input

min

min(Number, Number)Number

  • Returns the minimum of the two inputs

max

max(Number, Number)Number

  • Returns the maximum of the two inputs