数学講師2919682 views
中学英語814342 views
高校日本史191140 views
高校物理163190 views
中学理科1634294 views
高校生物553547 views
中学数学625514 views
ヒストリア296125 views
雑学1474397 views
Computer370413 views
Help
Tools

English

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.