An Overview Of Julia’s Operators. A quick look at all of the operators... | by Emmett Boudreau | Towards Data Science

For those interested in Julia, the world of Julia can be a confusing and scary one to enter. This is not only true of the methodology that Julia is normally written with, utilizing different programming concepts like multiple dispatch, but this is also true for more basic mathematical functions, such as addition or subtraction.
One of the most essential things to learn when picking up a new programming language is almost certainly the operators in that language. Julia has some pretty unique operators that are not all necessarily standardized across the entire scope of programming computers. With that in mind, let us take a look at some of these operators and what their function is in the language.
The most important and foundational operators in Julia are the arithmetic operators. These operators are used for assertion and mathematical expression in Julia, performing the exact arithmetic associated with the char used to represent the operator in Julia.
The assertion operator is one operator that most programmers are likely familiar with. This is represented by the = sign, and is typically used to set variable aliases equal to some sort of type.
The unary plus is the typical use of the addition operator, only placed on one variable. This will perform the identity operation. The identity operation is the operation which represents a combination of a given quantity and another quantity where the quantity remains static. For example, the additive identity is 0 since x + 0 = 0 + x = x. This is represented in Julia as a unary operator, which means that it is only used on one argument. We can call it by using the + char immediately before a variable call, like so:
+x
The unary minus operator is represented the same way as the unary plus operator. However, this operator performs dramatically different arithmetic. This operator is used to map values to their additive inverse. This basically just means that it negates the number. In other words, in Julia we can use the unary minus in order to represent a negative — which I think is natural and cool. This really plays into their “ just like in the papers” methodology, which I think is cool.
-x
Binary plus performs normal addition.
x + y
Binary minus performs normal subtraction.
x - y
The times operator is used to perform normal multiplication.
x * y
Who would have thought? The division operator is used to perform division!
x / y
This operator will perform division, but will always return a rounded integer:
x ÷ y
I think that this one is pretty useless, as I do not know what numpad keys to press to create that symbol, and you can simply use the round() method in order to get a float into an integer.
The inverse divide operator divides the second provided argument by the first, rather than the opposite.
x \ y
The power operator in Julia is ^, which always leaves me confused whenever I work with Python and try to call the Xor operator, ^, thinking it is going to give me an exponent.
x ^ 2
The remainder operator will return the remainder of division between two arguments.
x % y
Though not very exciting, boolean operators are also pretty important. These operators are meant to be used exclusively on bool types, as one might expect. Bare with me, I understand that most likely know all of the operators that we have looked at so far, but to get to the real meat of the Julian operators we must first go through the relatively rudimentary stuff.
The negation operator is another unary operator that will change the value of a given boolean to the opposite. It is represented with an explanation point.
!x
The boolean and operator is ripped straight from Bash in Julia. It is represented as &&.
x && y
The other conjunction operator is the or operator, which is represented with ||.
In computer programming, a bitwise operation operates on a bit string, a bit array or a binary numeral at the level of its individual bits. This usually just means that the operators are used to change individual bits in an operator.
The bitwise not operator is represented with ~, and is a unary operator.
~100
The bitwise and operator is represented with an amperstand, and is a binary operator.
x & y
The bitwise or operator is represented with a tube, |, and is also a binary operator.
x | y
Bitwise xor is represented with this thing ⊻, but you can also use the xor() method, which is what I usually do.
x ⊻ y
The logical shift right operator is represented with three right arrows, and is a binary operator.
x >>> y
The arithmetical shift right is represented with only two right arrows, and is also a binary operator.
x >> y
Both logical and arithmetical shifts left are combined into only two arrows going left. This is of course a binary operator, as well.
x << y
Every binary bitwise or arithmetic operator in the Julia language comes with an updating counter-part. These operators are used to update variable aliases with new types. The updating versions of the operators we just went over are
+=  -=  *=  /=  \=  ÷=  %=  ^=  &=  |=  ⊻=  >>>=  >>=  <<=
The last form of basic operators are the vectorized versions of the any binary arithmetic operation. This is represented by a dot in front of the operator. These are of course meant to be used on an iterable vector or array. The vectorized versions of these operators are as follows:
.+ .- .* ./ .\ .% .^
Comparison operators are used to return a boolean type from two arguments based on some condition. This condition can be numerical, equality, or even more.
The equality operator returns true if the values are equal.
x == y
The inequality operator returns true if the values are not equal.
x != y
The less than operator returns true if the first argument is less than the second argument.
x < y
The greater than operator returns true if the second argument is less than the first argument.
x > y
We can make both the less than and greater than operators become less than or equal to and greater than or equal to operators by simply adding an equals sign after the operator.
x >= yy <= x
Unfortunately the most exciting on this list is the sub-type operator. The sub-type operator has two uses. It is a binary operator that takes types. This operator is represented with <:. The first use is to assert a sub-type to any abstract type. For example,
abstract type AbstractTuber endstruct Potato <: AbstractTuber data::Array end
This operator can also be used to return a boolean for comparisons, hence why it is in this section:
x <: y
We can pretend that this operator means “ is a sub-type of.” If you would like to read more about sub-types in Julia as a general concept, and the usage of this operator for type hierarchies in Julia, I wrote an entire article on it you can check out here:
towardsdatascience.com
I decided to write this article because the Julia language does have some notable differences between a lot of other competing languages in its domain. It can often get confusing when switching from language to language and working with different operators, and furthermore it might be nice for newer programmers to be aware of all the operators in their language. As boring as this was to write, I do think it might be helpful for anyone coming into Julia with the intention of learning the language. Thank you very much for reading my article, I appreciate it!