Numbers

using AbstractTrees
AbstractTrees.children(t::Type) =
    filter(t->isdefined(Base, Symbol(t)) || isdefined(Core, Symbol(t)), subtypes(t))
print_tree(Number)
Number
├─ Complex
└─ Real
   ├─ AbstractFloat
   │  ├─ BigFloat
   │  ├─ Float16
   │  ├─ Float32
   │  └─ Float64
   ├─ AbstractIrrational
   │  └─ Irrational
   ├─ Integer
   │  ├─ Bool
   │  ├─ Signed
   │  │  ├─ BigInt
   │  │  ├─ Int128
   │  │  ├─ Int16
   │  │  ├─ Int32
   │  │  ├─ Int64
   │  │  └─ Int8
   │  └─ Unsigned
   │     ├─ UInt128
   │     ├─ UInt16
   │     ├─ UInt32
   │     ├─ UInt64
   │     └─ UInt8
   └─ Rational
Core.RealType
Real <: Number

Abstract supertype for all real numbers.

source

Integer types

Core.BoolType
Bool <: Integer

Boolean type, containing the values true and false.

Bool is a kind of number: false is numerically equal to 0 and true is numerically equal to 1. Moreover, false acts as a multiplicative "strong zero" against NaN and Inf:

julia> [true, false] == [1, 0]
true

julia> 42.0 + true
43.0

julia> 0 .* (NaN, Inf, -Inf)
(NaN, NaN, NaN)

julia> false .* (NaN, Inf, -Inf)
(0.0, 0.0, -0.0)

Branches via if and other conditionals only accept Bool. There are no "truthy" values in Julia.

Comparisons typically return Bool, and broadcasted comparisons may return BitArray instead of an Array{Bool}.

julia> [1 2 3 4 5] .< pi
1×5 BitMatrix:
 1  1  1  0  0

julia> map(>(pi), [1 2 3 4 5])
1×5 Matrix{Bool}:
 0  0  0  1  1

See also trues, falses, ifelse.

source
Core.UnsignedType
Unsigned <: Integer

Abstract supertype for all unsigned integers.

Built-in unsigned integers are printed in hexadecimal, with prefix 0x, and can be entered in the same way.

Examples

julia> typemax(UInt8)
0xff

julia> Int(0x00d)
13

julia> unsigned(true)
0x0000000000000001
source
Core.UInt8Type
UInt8 <: Unsigned <: Integer

8-bit unsigned integer type.

Printed in hexadecimal, thus 0x07 == 7.

source
Core.UInt16Type
UInt16 <: Unsigned <: Integer

16-bit unsigned integer type.

Printed in hexadecimal, thus 0x000f == 15.

source
Core.UInt32Type
UInt32 <: Unsigned <: Integer

32-bit unsigned integer type.

Printed in hexadecimal, thus 0x0000001f == 31.

source
Core.UInt64Type
UInt64 <: Unsigned <: Integer

64-bit unsigned integer type.

Printed in hexadecimal, thus 0x000000000000003f == 63.

source
Core.UInt128Type
UInt128 <: Unsigned <: Integer

128-bit unsigned integer type.

Printed in hexadecimal, thus 0x0000000000000000000000000000007f == 127.

source
Core.SignedType
Signed <: Integer

Abstract supertype for all signed integers.

source
Core.Int8Type
Int8 <: Signed <: Integer

8-bit signed integer type.

Represents numbers n ∈ -128:127. Note that such integers overflow without warning, thus typemax(Int8) + Int8(1) < 0.

See also Int, widen, BigInt.

source
Core.Int16Type
Int16 <: Signed <: Integer

16-bit signed integer type.

Represents numbers n ∈ -32768:32767. Note that such integers overflow without warning, thus typemax(Int16) + Int16(1) < 0.

See also Int, widen, BigInt.

source
Core.Int32Type
Int32 <: Signed <: Integer

32-bit signed integer type.

Note that such integers overflow without warning, thus typemax(Int32) + Int32(1) < 0.

See also Int, widen, BigInt.

source
Core.Int64Type
Int64 <: Signed <: Integer

64-bit signed integer type.

Note that such integers overflow without warning, thus typemax(Int64) + Int64(1) < 0.

See also Int, widen, BigInt.

source
Core.Int128Type
Int128 <: Signed <: Integer

128-bit signed integer type.

Note that such integers overflow without warning, thus typemax(Int128) + Int128(1) < 0.

See also Int, widen, BigInt.

source

Floating-point types

Core.Float16Type
Float16 <: AbstractFloat <: Real

16-bit floating point number type (IEEE 754 standard). Binary format is 1 sign, 5 exponent, 10 fraction bits.

source
Core.Float32Type
Float32 <: AbstractFloat <: Real

32-bit floating point number type (IEEE 754 standard). Binary format is 1 sign, 8 exponent, 23 fraction bits.

The exponent for scientific notation should be entered as lower-case f, thus 2f3 === 2.0f0 * 10^3 === Float32(2_000). For array literals and comprehensions, the element type can be specified before the square brackets: Float32[1,4,9] == Float32[i^2 for i in 1:3].

See also Inf32, NaN32, Float16, exponent, frexp.

source
Core.Float64Type
Float64 <: AbstractFloat <: Real

64-bit floating point number type (IEEE 754 standard). Binary format is 1 sign, 11 exponent, 52 fraction bits. See bitstring, signbit, exponent, frexp, and significand to access various bits.

This is the default for floating point literals, 1.0 isa Float64, and for many operations such as 1/2, 2pi, log(2), range(0,90,length=4). Unlike integers, this default does not change with Sys.WORD_SIZE.

The exponent for scientific notation can be entered as e or E, thus 2e3 === 2.0E3 === 2.0 * 10^3. Doing so is strongly preferred over 10^n because integers overflow, thus 2.0 * 10^19 < 0 but 2e19 > 0.

See also Inf, NaN, floatmax, Float32, Complex.

source

Irrational

Base.AbstractIrrationalType
AbstractIrrational <: Real

Number type representing an exact irrational value, which is automatically rounded to the correct precision in arithmetic operations with other numeric quantities.

Subtypes MyIrrational <: AbstractIrrational should implement at least ==(::MyIrrational, ::MyIrrational), hash(x::MyIrrational, h::UInt), and convert(::Type{F}, x::MyIrrational) where {F <: Union{BigFloat,Float32,Float64}}.

If a subtype is used to represent values that may occasionally be rational (e.g. a square-root type that represents √n for integers n will give a rational result when n is a perfect square), then it should also implement isinteger, iszero, isone, and == with Real values (since all of these default to false for AbstractIrrational types), as well as defining hash to equal that of the corresponding Rational.

source

Rational

Base.RationalType
Rational{T<:Integer} <: Real

Rational number type, with numerator and denominator of type T. Rationals are checked for overflow.

source

Complex types

Base.ComplexType
Complex{T<:Real} <: Number

Complex number type with real and imaginary part of type T.

ComplexF16, ComplexF32 and ComplexF64 are aliases for Complex{Float16}, Complex{Float32} and Complex{Float64} respectively.

See also: Real, complex, real.

source
Base.ComplexF16Type
Complex{T<:Real} <: Number

Complex number type with real and imaginary part of type T.

ComplexF16, ComplexF32 and ComplexF64 are aliases for Complex{Float16}, Complex{Float32} and Complex{Float64} respectively.

See also: Real, complex, real.

source
Base.ComplexF32Type
Complex{T<:Real} <: Number

Complex number type with real and imaginary part of type T.

ComplexF16, ComplexF32 and ComplexF64 are aliases for Complex{Float16}, Complex{Float32} and Complex{Float64} respectively.

See also: Real, complex, real.

source
Base.ComplexF64Type
Complex{T<:Real} <: Number

Complex number type with real and imaginary part of type T.

ComplexF16, ComplexF32 and ComplexF64 are aliases for Complex{Float16}, Complex{Float32} and Complex{Float64} respectively.

See also: Real, complex, real.

source