Pi/Pie Author
16 Jun 2024

Arithmetic operations in Pi/Pie

The arithmetic operations in Pi/Pie are the same as Python.

x = 3
y = 2

a = x + y
b = x - y

m = x * y
p = x**y

d = x / y
r = x % y

** means the power operator so p is 9. % is the modulo operator so r is 1.

Operator as function

This section will be changed in the future. The plus operator (+) is the special form of __add__ function of number class N, Z, Q, R, C. So 1 + 2 is equal to:

1.__add__(2)

But Pi/Pie IDE should not support this confusing expression.

The power operator is formally equal to __power__ function and the argument type of it is Z. So

3**0.6

is invalid. Whether an operator is valid or not is judged by the argument type of operator function.

Support of operations like +=

I will not support += like operations in Pi/Pie.