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›Data Types

Data Types

Int, Float64, String, Bool; string interpolation ($) and text↔number conversion.

Simple enough for a 5-year-old to understand

Basic types and interpolation

To embed a value into a string, use $degisken or $(ifade).

Example code
1
number = 7
Int.
VariableInt.
2
decimal = 3.14
Float64.
VariableFloat64.
3
text = "Julia"
String.
VariableString.
4
println("$number $decimal $text")
7 3.14 prints Julia.
Output / Input7 3.14 prints Julia.
VariableOutput / Input
💡 Hint: Embed with $degisken; use $(a + b) for expressions.

About this topic

Julia's numerical type system is rich: integers of various widths, floating-point numbers, rational numbers, and complex numbers are built into the core of the language. Scientific computing requires this richness.

The default integer type is determined by the system architecture and has a fixed width. This brings the risk of overflow: when you add one to the maximum value, the result silently wraps around to negative. Julia does not warn you about this, making this choice for the sake of speed.

There is also an integer type that can grow indefinitely, but it is not the default; you must explicitly request it. Not knowing this distinction in factorial and combinatorial calculations silently produces incorrect results.

What you will learn

  • Basic numerical types
  • Overflow behavior
  • The unlimited integer type
  • Division operators
  • Type conversions

Who is this for?

  • Researchers doing numerical computing
  • Those working with large numbers
  • Those surprised by the division result

When to use?

It is mandatory to use the unlimited integer type in combinatorial, cryptography, and factorial calculations; otherwise, the results will silently turn out wrong.

If precision is critical in decimal calculations, high-precision types are available; rational numbers can also be preferred for monetary calculations.

Common mistakes

Wrong

println(7 / 2)
println(typeof(7 / 2))

In Julia, the division operator always returns a floating-output; even if two integers are divided, the result is 3.5 and its type is floating-point. A separate function or special division sign is used for integer division. This behavior is consistent with MATLAB and Python, but different from the C family.

Correct

println(div(7, 2))
println(typeof(div(7, 2)))

Wrong

function faktoriyel(n)
    sonuc = 1
    for i in 1:n
        sonuc = sonuc * i
    end
    return sonuc
end
println(faktoriyel(25))

The default integer type has a fixed width and the factorial of twenty-five does not fit; the result silently overflows and returns a negative or meaningless value. You will not get an error message. If large results are expected, you need to start with the unlimited integer type.

Correct

function faktoriyel(n)
    sonuc = big(1)
    for i in 1:n
        sonuc = sonuc * i
    end
    return sonuc
end
println(faktoriyel(25))

Wrong

x = 3.7
y::Int = x

A floating-point number cannot be directly assigned to an integer type; an InexactError is thrown because the conversion leads to data loss. Julia does not truncate silently; it expects you to explicitly state what you want: to round, or to floor?

Correct

x = 3.7
y = round(Int, x)

Frequently asked questions

Why does overflow happen silently?

Because checking for overflow in every operation would noticeably slow down numerical code. Julia chose speed and left the check to the programmer. It is your responsibility to use the unlimited integer type in calculations where the result can grow.

How is type conversion done?

The name of the target type is called like a function. If there is going to be data loss, you will get an error; if you want this, you must explicitly use rounding or truncation functions. This strictness prevents silent numerical errors.

What are rational numbers used for?

They store fractions precisely and do not produce floating-point rounding errors. If precision is required when working with values like one-third, it is much more accurate than a floating-point number; the cost is speed and memory usage.

Summary

The division operator always returns a floating-point result.

The default integer type can overflow without giving a warning.

The unlimited integer type must be requested explicitly.

Conversions that lead to data loss throw an error.

Rational numbers preserve fractions exactly.

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