HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to JuliaVariablesData TypesOperatorsStringsArraysConditions (if / else)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables & Types
🔢 Numbers & Math
✍️ String
📚 Array & Dictionary
🔀 Condition & Loop
🧩 Function
Julia›Operators

Operators

Math (+ - * / ÷ % ^), comparison (== != < >) and logic (&& || !).

Simple enough for a 5-year-old to understand

Math operators

/ always returns a decimal (7/2 = 3.5). For integer division, use div(a,b). ^ calculates powers.

Example code
1
println(7 + 3)
10
Output / Input10
2
println(7 / 2)
3.5 (always decimal)
Output / Input3.5 (always decimal)
3
println(div(7, 2))
3 (integer division)
Output / Input3 (integer division)
4
println(7 % 2)
1 (remainder)
Output / Input1 (remainder)
5
println(2 ^ 10)
1024 (power)
Output / Input1024 (power)
Output / Input
💡 Hint: For integer division, use div(a,b); for powers, use ^ (not ** as in other languages).

🎯 Exercise & Practice

Test what you've learned — answer, write code, check instantly. (2 left)

1.How to do integer division in Julia (without dropping the decimal)?
2.Print the remainder of dividing 23 by 4.

🎯 Expected output: 3

Loading editor…

About this topic

Julia's operators are designed to be close to mathematical notation. A caret is used for exponentiation, chained comparisons can be written, and Unicode symbols are directly accepted for certain operations.

The most important feature unique to Julia is broadcasting: when you put a dot in front of a function or operator, the operation is applied to each element of the array individually. This is the standard way to perform vector operations without writing loops.

Broadcasting forms the characteristic look of Julia code. The presence or absence of a dot causes the operation to take on a completely different meaning; the difference between matrix multiplication and element-wise multiplication is a single dot.

What you will learn

  • Arithmetic and comparison operators
  • Chained comparison
  • Broadcasting
  • Logical operators
  • Integer division operators

Who is this for?

  • Researchers who will perform vector operations
  • Those transitioning from MATLAB
  • Those getting a dimension mismatch error

When to use?

Broadcasting is used when it is necessary to apply the same operation to all elements of an array; it is both shorter and faster than writing a loop.

In matrix operations, dotted and undotted operators carry different meanings; you need to choose knowingly which one you want.

Common mistakes

Wrong

dizi = [1, 2, 3]
println(sqrt(dizi))

The square root function expects a single number; calling it with an array results in a MethodError. Broadcasting must be used to apply it to each element. Julia is clear on this: scalar operations and vector operations are different things and are separated by a dot.

Correct

dizi = [1, 2, 3]
println(sqrt.(dizi))

Wrong

a = [1 2; 3 4]
b = [5 6; 7 8]
println(a * b)

There is no error here, but the intention might be wrong: undotted multiplication is matrix multiplication, not element-wise multiplication. If you want to multiply corresponding elements, you need to use the dotted version. This difference also exists in MATLAB and silently produces incorrect results.

Correct

a = [1 2; 3 4]
b = [5 6; 7 8]
println(a .* b)

Wrong

x = 5
if 0 < x & x < 10
    println("in range")
end

The single-character sign performs a bitwise operation and has a higher precedence than comparison, giving an unexpected result. The double-character format should be used for the logical AND operation. Julia also directly supports chained comparison, which is the most readable way.

Correct

x = 5
if 0 < x < 10
    println("in range")
end

Frequently asked questions

How exactly does broadcasting work?

It applies the operation to each element of the array individually and produces a new array of the same size. If there are multiple arrays, their dimensions must be compatible. Chained broadcasts are merged in a single pass, so intermediate arrays are not created and it is fast.

Does chained comparison really work?

Yes, Julia directly supports mathematical notation and the middle expression is evaluated only once. In many languages, the same syntax silently gives an incorrect result; Julia behaves as you would expect in this regard.

Should I use Unicode operators?

It is optional; every Unicode operator has an ASCII equivalent. It increases readability when writing code close to mathematical formulas, but it can be debatable within a team in terms of typing ease.

Summary

The broadcasting operation is done with a dot.

Undotted multiplication is matrix multiplication.

Logical operators are double characters.

Chained comparison is supported.

Integer division is a separate operation.

HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code