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 |
|
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 |
|
Question
-
From the example above, why is
2.999999 < 3
equal totrue
but
2.9999999 < 3
equal tofalse
? -
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¶
power¶
log¶
log(base: Number, value: Number) ➟ Number
Warning
- The program halts with this error if the log value is invalid (NaN or Inf):