In this Julia Tutorial, we will learn what Arithmetic Operators are available in Julia and how to use them with examples.

The following arithmetic operators are supported on all primitive numeric types:

ExpressionNameDescription
+xunary plusthe identity operation
-xunary minusmaps values to their additive inverses
x + ybinary plusperforms addition
x - ybinary minusperforms subtraction
x * ytimesperforms multiplication
x / ydivideperforms division
x ÷ yinteger dividex / y, truncated to an integer
x \ yinverse divideequivalent to y / x
x ^ ypowerraises x to the yth power
x % yremainderequivalent to rem(x,y)

Unary Plus

julia> x = 10
10

julia> +x
10

Unary Minus

julia> x = 10
10

julia> -x
-10

Binary Plus

julia> x = 10
10

julia> y = 15
15

julia> x + y
25

Binary Minus

julia> x = 10
10

julia> y = 15
15

julia> x - y
-5

Multiplication

julia> x = 10
10

julia> y = 15
15

julia> x * y
150

Division

julia> x = 10
10

julia> y = 15
15

julia> x / y
0.6666666666666666

Integer Division

julia> x = 10
10

julia> y = 3
3

julia> x ÷ y
3

Inverse Division

julia> x = 10
10

julia> y = 3
3

julia> x \ y
0.3

Power

julia> x = 11
11

julia> y = 4
4

julia> x ^ y
14641

Remainder

julia> x = 11
11

julia> y = 4
4

julia> x % y
3

Conclusion

In this Julia Tutorial, we learned about Julia Arithmetic Operators with examples for each operator.