Python and Powers Math

时光毁灭记忆、已成空白 提交于 2019-11-27 13:53:16

Operator ^ is a bitwise operator, which does "bitwise exclusive or".
More: http://wiki.python.org/moin/BitwiseOperators

The power operator is **, like 8**3 which equals to 512.
Ref: http://docs.python.org/reference/expressions.html#the-power-operator

Sam Dolan

The symbols represent different operators.

The ^ represents the bitwise exclusive or (XOR).

Each bit of the output is the same as the corresponding bit in x if that bit in y is 0, and it's the complement of the bit in x if that bit in y is 1.

** represents the power operator. That's just the way that the language is structured.

It's just that ^ does not mean "exponent" in Python. It means "bitwise XOR". See the documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!