A number literal writes a numeric value directly in source code with digits instead of referring to a named variable. Julia accepts decimal, binary, and hexadecimal forms, while decimal notation is usually the practical default. section 2.7
Literal spelling also helps determine the value’s type. Ordinary integers default to Int64, decimal floating-point values to Float64, and suffixes such as f0 select Float32. Other types can be produced with conversions such as Int8(42) or Float16(3.5). section 2.4 section 2.3
Common literal forms include:
- 42 is an Int64 integer literal, 0x42 is an unsigned hexadecimal literal, 0.42 is Float64, 0.42f0 is Float32, and 3//4 is Rational{Int64}. section 11.4.4
- Use an explicit conversion when a desired type lacks a convenient literal form, such as Float16(3.5) or Int8(42). section 2.4 section 11.4.4
- Write 34.23f0 rather than 34.23f: Julia interprets a trailing f without 0 as multiplication by a variable named f. section 2.4
Inspecting literal types
julia> typeof(42) Int64 julia> typeof(0.42) Float64 julia> typeof(0.42f0) Float32 julia> typeof(3//4) Rational{Int64} section 11.4.4
Julia can extend literal syntax with string macros: big"42" creates a BigInt during parsing, and a custom int8"42" form can create an Int8 value. This reaches parse-time behavior without developing the broader macro system. section 11.4.4





