Julia Data Types Tutorial
last modified November 18, 2026
Julia is dynamically typed, but every value still has a concrete type. This tutorial introduces the built-in data types — integers, floating-point numbers, booleans, and characters — and shows how to inspect, test, convert, and promote them.
A value's type matters because Julia chooses the implementation of an operation
from the types of its operands. We look at typeof, the
isa operator, the subtype operator <:,
convert, and promote. The examples were verified with
Julia 1.13.4.
Integer Types
An integer is a whole number without a fractional part. Julia provides several
integer types that differ in size and range; the default is Int.
println(typeof(42)) println(typeof(42) === Int) println(typemin(Int), " ", typemax(Int)) println(sizeof(Int))
On a 64-bit platform Int is an alias for Int64, so
typeof(42) prints Int64 and the comparison with
Int is true. The typemin and typemax
functions return the smallest and largest representable values, and
sizeof reports that a value occupies eight bytes.
$ julia main.jl Int64 true -9223372036854775808 9223372036854775807 8
Floating-Point Types
A floating-point number approximates a real number with a fractional part.
Julia's default is Float64, the double-precision type.
x = 3.14 println(typeof(x)) println(typeof(Float32(1.5))) println(eps(Float64)) println(1.0 / 3)
The literal 3.14 has type Float64;
Float32(1.5) explicitly requests single precision. The
eps function returns the machine epsilon — the gap between
1.0 and the next larger floating-point number — which shows that floating-point
values have finite precision. The last line demonstrates that one third cannot
be represented exactly.
$ julia main.jl Float64 Float32 2.220446049250313e-16 0.3333333333333333
Booleans
A boolean is a value that is either true or false.
Its type is Bool.
println(typeof(true), " ", typeof(false)) println(true + true) println(Int(true), " ", Int(false)) println(true == 1, " ", false == 0) println(3 > 2)
In Julia Bool is a subtype of Integer, so booleans can
be used in arithmetic: true + true is 2, and
Int(true) is 1. Comparisons such as >
return a boolean. Note that true == 1 is true because the two
values compare equal.
$ julia main.jl Bool Bool 2 1 0 true true true
Characters
A character is a single Unicode symbol. Julia's Char type stores a
32-bit code point.
c = 'A'
println(typeof(c))
println(Int(c))
println(Char(0x1F600))
println('Ω', " ", Int('Ω'))
Character literals use single quotes. Int(c) returns the Unicode
code point of the character, here 65 for 'A'. The
reverse conversion Char(code) builds a character from a code point;
the emoji and the Greek capital omega show that characters are not limited to
ASCII.
$ julia main.jl Char 65 😀 Ω 937
Inspecting Types with typeof
The typeof function reports the concrete type of a value; it is the
most direct way to find out what Julia has inferred.
for v in (7, 3.5, true, 'x', "hi")
println(typeof(v), " ", v)
end
We iterate over a tuple of values of different types and print each type beside
the value. The results confirm the default types introduced above:
Int64 for an integer literal, Float64 for a decimal,
Bool, Char, and String.
$ julia main.jl Int64 7 Float64 3.5 Bool true Char x String hi
Testing Types with isa
The isa operator tests whether a value belongs to a given type. It
can be written as a function or in infix form.
println(isa(10, Int))
println(10 isa Int)
println(10 isa Float64)
println("abc" isa AbstractString)
println(3.0 isa Real)
The first two lines are equivalent. The remaining lines show that isa
also accepts abstract types: a string is an AbstractString, and a
floating-point number is a Real. The result is always a
Bool.
$ julia main.jl true true false true true
The Subtype Operator <:
The subtype operator <: asks whether one type is a subtype of
another — whether every instance of the first is also an instance of the second.
println(Int <: Integer) println(Integer <: Real) println(Int <: Real) println(Float64 <: Number) println(Int <: Float64) println(String <: Any)
Julia's numeric types form a hierarchy: Int is an
Integer, which is a Real, which is a
Number. The relation is transitive, so Int <: Real
holds. It is not the same as convertibility: an Int can be
converted to a Float64, but it is not a subtype of it. Every type is
a subtype of Any.
$ julia main.jl true true true true false true
Conversion
Conversion produces a value of a requested type from a value of another type.
The convert function and the type constructors are the usual tools.
println(convert(Int, 3.0)) println(convert(Float64, 3)) println(floor(Int, 3.7), " ", round(Int, 3.7), " ", ceil(Int, 3.7)) println(parse(Int, "42")) println(string(42))
Converting 3.0 to Int succeeds because the value is
lossless; converting 3.7 directly to Int would raise an
InexactError. For inexact values use floor,
round, or ceil, which state explicitly how the
fractional part is handled. The parse function turns a string into a
number and string turns a value into text.
$ julia main.jl 3 3.0 3 4 4 42 42
Promotion
Promotion brings several values to a common type so that an operation can work on them. This is why adding an integer and a float yields a float.
println(promote(1, 2.5)) println(typeof(promote(1, 2.5)[1])) println(promote(Int8(1), Int16(2))) println(promote_type(Int, Float64)) println(1 + 2.5, " ", typeof(1 + 2.5))
promote returns a tuple of converted values, here both
Float64. When the inputs are Int8 and
Int16, the common type is Int16. The
promote_type function reports the common type without converting
any values. The final line shows the practical effect: 1 + 2.5 is
computed as Float64 arithmetic.
$ julia main.jl (1.0, 2.5) Float64 (1, 2) Float64 3.5 Float64
Arbitrary-Precision Numbers
When the fixed-size types are not enough, Julia offers arbitrary-precision integers and floats from the standard library.
n = big(2)^100 println(n) println(typeof(n)) f = big(1) / 3 println(f) println(typeof(f))
The big function promotes a value to BigInt or
BigFloat. Exponentiation then grows the integer well beyond the
range of Int, and the division keeps many more significant digits
than Float64 would.
$ julia main.jl 1267650600228229401496703205376 BigInt 0.3333333333333333333333333333333333333333333333333333333333333333333333333333348 BigFloat
Best Practices for Data Types
A few simple habits make type handling predictable.
- Let Julia infer types: write
42rather thanInt64(42)unless a specific type is required. - Prefer concrete types in performance-critical code: a
concrete type such as
Float64is easier to optimize than an abstract one. - Handle inexact conversion explicitly: use
floor,round, orceilinstead of expectingconvertto succeed. - Use
isaand<:for checks: they are clearer than comparing type names as strings.
Source
Julia Mathematical Operations and Elementary Functions documentation
In this article we have worked with Julia's built-in data types: integers, floats, booleans, characters, and the tools for inspecting and converting them. Variables and type inference are covered in Julia variables, and the relationships between types are explored in Julia abstract types. Operators and their promotion rules are described in Julia operators.
Author
List all Julia tutorials.