Formerly of Apple, I currently write software to solve all manner of interesting problems. I work and live in Coral Gables, FL with my beautiful wife and two kids.
Ah yes...exponentiation. There's a mildly interesting (mostly annoying) history around the choice of operator for it. Back in the good ol' days of C, it was much more common to find oneself twiddling bits than doing higher order math. A very useful operation if you are dealing with bits is the bit-wise XOR. In mathematics, this operation is usually represented with the ⊻ character. However, since this is not part of the base ASCII set of characters, the developers of C chose to use the next closest thing: ^.
Of course, when more feature-full languages such as Perl came along and wanted to have an operator for exponentiation, they were stuck. While ^ is typically used in mathematics for this operation, C already established the tradition of using this for XOR. Thus was ** born. Ruby, Python, Javascript, and a whole host of other languages followed suit.
But not Julia. Julia made two decisions early on in its development. First, Julia is very mathematics focused and tries to keep as close to traditional conventions from mathematics as possible. Second, Julia (like Swift and many other languages today) embraced the full unicode set for operators. Julia also made it easy to use these operators by allowing one to type \xor at the REPL, hit <TAB>, et voila:
julia>2^38julia>2⊻31
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ah yes...exponentiation. There's a mildly interesting (mostly annoying) history around the choice of operator for it. Back in the good ol' days of C, it was much more common to find oneself twiddling bits than doing higher order math. A very useful operation if you are dealing with bits is the bit-wise XOR. In mathematics, this operation is usually represented with the
⊻
character. However, since this is not part of the base ASCII set of characters, the developers of C chose to use the next closest thing:^
.Of course, when more feature-full languages such as Perl came along and wanted to have an operator for exponentiation, they were stuck. While
^
is typically used in mathematics for this operation, C already established the tradition of using this for XOR. Thus was**
born. Ruby, Python, Javascript, and a whole host of other languages followed suit.But not Julia. Julia made two decisions early on in its development. First, Julia is very mathematics focused and tries to keep as close to traditional conventions from mathematics as possible. Second, Julia (like Swift and many other languages today) embraced the full unicode set for operators. Julia also made it easy to use these operators by allowing one to type
\xor
at the REPL, hit<TAB>
, et voila: