りんご214542 views
いろは3017544 views
高校日本史190746 views
高校化学2928089 views
中学数学624358 views
数学講師2897750 views
高校国語789049 views
世界の国565759 views
中学英語812563 views
LaTeX963621 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.