高校国語786056 views
高校化学2914866 views
いろは2991447 views
高校倫理1434453 views
高校生物550125 views
中学英語809308 views
ヒストリア285185 views
小学理科717666 views
中学社会667365 views
中学数学621815 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.