example.org 1.2 KB

Simple arithmetic operations

Add, multiply, substract

1+2*3-4

val it = 3 : int

Divide

3/4

:results: stdIn:1.2-1.5 Error: operator and operand don't agree [overload conflict] operator domain: real * real operand: [int ty] * [int ty] in expression: :end:

Dividing works only on real numbers, not on integers.

But there is integer division as well:

3 div 2

:results: val it = 1 : int :end:

Modulo

5 mod 2

val it = 1 : int

Negative numbers

~3+4

:results: val it = 1 : int :end: