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
└─ RationalCore.Number — Type
NumberAbstract supertype for all number types.
Integer types
Core.Bool — Type
Bool <: IntegerBoolean 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 1Core.Unsigned — Type
Unsigned <: IntegerAbstract 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)
0x0000000000000001Core.UInt8 — Type
UInt8 <: Unsigned <: Integer8-bit unsigned integer type.
Printed in hexadecimal, thus 0x07 == 7.
Core.UInt16 — Type
UInt16 <: Unsigned <: Integer16-bit unsigned integer type.
Printed in hexadecimal, thus 0x000f == 15.
Core.UInt32 — Type
UInt32 <: Unsigned <: Integer32-bit unsigned integer type.
Printed in hexadecimal, thus 0x0000001f == 31.
Core.UInt64 — Type
UInt64 <: Unsigned <: Integer64-bit unsigned integer type.
Printed in hexadecimal, thus 0x000000000000003f == 63.
Core.UInt128 — Type
UInt128 <: Unsigned <: Integer128-bit unsigned integer type.
Printed in hexadecimal, thus 0x0000000000000000000000000000007f == 127.
Core.Signed — Type
Signed <: IntegerAbstract supertype for all signed integers.
Core.Int16 — Type
Int16 <: Signed <: Integer16-bit signed integer type.
Represents numbers n ∈ -32768:32767. Note that such integers overflow without warning, thus typemax(Int16) + Int16(1) < 0.
Core.Int32 — Type
Int32 <: Signed <: Integer32-bit signed integer type.
Note that such integers overflow without warning, thus typemax(Int32) + Int32(1) < 0.
Core.Int64 — Type
Int64 <: Signed <: Integer64-bit signed integer type.
Note that such integers overflow without warning, thus typemax(Int64) + Int64(1) < 0.
Core.Int128 — Type
Int128 <: Signed <: Integer128-bit signed integer type.
Note that such integers overflow without warning, thus typemax(Int128) + Int128(1) < 0.
Base.GMP.BigInt — Type
BigInt <: SignedArbitrary precision integer type.
Floating-point types
Core.AbstractFloat — Type
AbstractFloat <: RealAbstract supertype for all floating point numbers.
Core.Float16 — Type
Float16 <: AbstractFloat <: Real16-bit floating point number type (IEEE 754 standard). Binary format is 1 sign, 5 exponent, 10 fraction bits.
Core.Float32 — Type
Float32 <: AbstractFloat <: Real32-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].
Core.Float64 — Type
Float64 <: AbstractFloat <: Real64-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.
Base.MPFR.BigFloat — Type
BigFloat <: AbstractFloatArbitrary precision floating point number type.
Irrational
Base.AbstractIrrational — Type
AbstractIrrational <: RealNumber 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.
Base.Irrational — Type
Irrational{sym} <: AbstractIrrationalNumber type representing an exact irrational value denoted by the symbol sym, such as π, ℯ and γ.
See also AbstractIrrational.
Rational
Base.Rational — Type
Rational{T<:Integer} <: RealRational number type, with numerator and denominator of type T. Rationals are checked for overflow.
Complex types
Base.Complex — Type
Complex{T<:Real} <: NumberComplex 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.
Base.ComplexF16 — Type
Complex{T<:Real} <: NumberComplex 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.
Base.ComplexF32 — Type
Complex{T<:Real} <: NumberComplex 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.
Base.ComplexF64 — Type
Complex{T<:Real} <: NumberComplex 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.