Does the "Int" Type really exist?

Hi,
1.- I’m finding the use of type “Int” and “Type{Int}” in some articles and documents,
2.- also some functions reply “things” when I used “Int” likes argument … but not the same if I use Type{Int} likes argument …
3.- I can´t find the word “Int” likes a type in the Julia Tree types ( include using the famouse “function showtypetree(T, level=0)”.
Below there is some code to show the “type Int’ s show”

println("Excuse me, I would like to know what kind of type is 'Int' and if is the same of 'Type{Int}'" )
println(" ")
#
println("-Concrete Int? and Type{Int} ? ", isconcretetype(Int), " y ", isconcretetype(Type{Int}))
println("-Abstract Int? and Type{Int} ? ", isabstracttype(Int), " y ", isabstracttype(Type{Int}))
println(" .... then please tell me de typeof 'Int'... ",typeof(Int), " and de typeof Type{Int} ... ",typeof(Type{Int}))
println(" ")
#
println("- Does Int equal to ...? ")
println(" Integer,  Int,   BigInt, Int128,  Int64,  Int32,  Int16,  Int8")
for e in [Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8]
    print("   ", isa(e,Int) )    
end
println(" ")
println(" ")
println("- Does Type{Int} equal to ...?? ")
#println(" Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8")
println(" Integer,  Int,   BigInt, Int128,  Int64,  Int32,  Int16,  Int8")
for e in [Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8]
    print("   ", isa(e,Type{Int}) )
end
println(" ")
println(" ")
println("- Subtypes of Int ? ")
#println(" Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8")
println(" Integer,  Int,   BigInt, Int128,  Int64,  Int32,  Int16,  Int8")
for e in [Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8]
    print("   ", <:(e,Int) )
end
println(" ")
println(" ")
println("- Subtypes of Type{Int} ? ")
#println(" Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8")
println(" Integer,  Int,   BigInt, Int128,  Int64,  Int32,  Int16,  Int8")
for e in [Integer, Int, BigInt, Int128, Int64, Int32, Int16, Int8]
    print("   ", <:(e,Type{Int}) )
end

From the docs:

Julia also defines the types Int and UInt , which are aliases for the system’s signed and unsigned native integer types respectively

# 32-bit system:
julia> Int
Int32
julia> UInt
UInt32

# 64-bit system:
julia> Int
Int64
julia> UInt
UInt64
4 Likes

Thank you, but is this exclusive for Julia on 32 bits system?. Because in my 64 bits system I can use 32 bits type s numbers.

I am not 100% what you are referring to with the exclusiveness.

The Int type is an easy way to refer to the “usual/natural” integer type per system, as the docs show – it is a Int32 on 32.bit systems and a Int64 on 64 bit systems.

You can still – if you want to – use Int32 wherever you like (but it might be wasting space on 64-bit machines, not completely sure). Or Int64 (but that might be expensive on 32 bit machines).

2 Likes

Int32 is only 32 bits, even on a 64-bit machine, just like Int8 is only 8 bits (e.g. when stored in an array). And yes, Int64 is likely to be slower on a 32-bit machine.

Int is the default integer type in Julia, e.g. it is the default type used for small literal integers like 1, since it is the widest “fast” integer type. It is also used to represent things like the lengths of arrays (since those can never be larger than typemax(UInt32) on a 32-bit system, where the memory addresses are only 32 bits wide, and usually cannot be larger than typemax(Int32) … I guess technically a BitArray could have length 8 * typemax(UInt32), but in practice this is not useful if all of your other data structures are limited).

2 Likes

Screenshot from 2023-05-22 13-34-42

OK , I can assume that “Int” is an alias of “Int64” in my system, but then I don 't understand the “isa function” reply as you can see above.
Julia 1.8.5 “pdf”

isa checks whether something is an instance of a type, not whether it is a subtype:

julia> 1 isa Int
true

julia> Int isa Int
false

julia> Int isa Type
true

Perhaps you are thinking of <: (“is a subtype of”):

julia> Int <: Int
true

julia> Int <: Integer
true
2 Likes

Okey thank you, I understand now what isa is doing.