'^' does not behave as expected - moderator (because it is pow and not XOR)

image

What is wrong here?

3 Likes
Python 2.7.18 (default, Oct  2 2021, 04:20:39) 
[GCC Apple LLVM 13.0.0 (clang-1300.0.29.1) on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = -3
>>> x^2
-1

:slight_smile:

2 Likes

The difference is that ^ is the power operator in Julia, whereas it is the XOR operator in Python (** is the Python power operator).

See Noteworthy Differences from other Languages · The Julia Language

4 Likes

I’ve taken the liberty to change the title to something a little more informative, and move the thread into a more appropriate category.

6 Likes