LaTeX958656 views
小学算数1197123 views
りんご198685 views
高校倫理1435630 views
いろは2995408 views
中学理科1627901 views
高校化学2916262 views
教育149101 views
数学講師2864925 views
MathPython493579 views

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.