# Are \`Int64\` and \`Float64\` of the same type?

**URL:** <https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574>\
**Category:** General Usage\
**Tags:** question, type\
**Created:** [April 27, 2024, 6:51pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574 "2024-04-27T18:51:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Post date:** [April 27, 2024, 6:51pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/1 "2024-04-27T18:51:13Z")

</div>

`typeof(Int64)` and `typeof(Float64)` are both `DataType`, but `Int64 isa Type{Int64}` while `!(Float64 isa Type{Int64})` and I would expect nothing besides the type of a value be utilized in the isa opperation. So I ask, are `Int64` and `Float64` of the same type?

I ask in part to contextualize [when Julia avoids specializing](https://docs.julialang.org/en/v1/manual/performance-tips/#Be-aware-of-when-Julia-avoids-specializing).

---

<div class="post-metadata">

**Author:** ![JeffreySarnoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeffreysarnoff/32/1980_2.png) [@JeffreySarnoff](https://discourse.julialang.org/u/JeffreySarnoff)\
**Post date:** [April 27, 2024, 8:32pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/2 "2024-04-27T20:32:30Z")

</div>

They are two [very] distinct types. Here area couple of ways to see that they are of different natures.

```julia
julia> typeof(1) == typeof(1.0)
false

julia> Int64 <: Integer, Float64 <: Integer
(true, false)

julia> Int64 <: AbstractFloat, Float64 <: AbstractFloat
(false, true)

```

Both are subtypes of Real, that does not make them the same.

```julia
julia> isa(1, Real)
true
julia> isa(1.0, Real)
true

```

---

<div class="post-metadata">

**Author:** ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Post date:** [April 27, 2024, 8:52pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/3 "2024-04-27T20:52:29Z")

</div>

```julia
x = Int64
y = Float64

```

I’m not asking if `x` and `y` are the same value (`x == y`) I’m asking if `x` and `y` are _of the same type_

In the case below, `z` and `w` are of the same type. Same question but for `x` and `y` instead.

```julia
z = 1
w = 2

```

---

<div class="post-metadata">

**Author:** ![abraemer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/abraemer/32/51403_2.png) [@abraemer](https://discourse.julialang.org/u/abraemer)\
**Post date:** [April 27, 2024, 8:58pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/4 "2024-04-27T20:58:12Z")

</div>

> [@Lilith](#):
>
> So I ask, are `Int64` and `Float64` of the same type?

I think the answer is a clear: Well yes but actually no 😅 It depends on the context.

Both are technically instances of `DataType` as shown by `typeof` meaning they have the same data layout.

However in practice, one often wants to differentiate between types (e.g. for specialization) and so there is a another way you can view them: As singleton instances of `Type{T}`. I think this is really a special case for the `isa` operator and does not really follow the conventional rules. This is somewhat explained in the manual here:  
[https://docs.julialang.org/en/v1/manual/types/#man-typet-type](https://docs.julialang.org/en/v1/manual/types/#man-typet-type)

So in some technical sense there are instances of the same type, but in a type theory sense they are singleton instances of an appropriate `Type{T}` and both things hold simultaneously.

---

<div class="post-metadata">

**Author:** ![Lilith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lilith/32/27492_2.png) [@Lilith](https://discourse.julialang.org/u/Lilith)\
**Post date:** [April 27, 2024, 9:18pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/5 "2024-04-27T21:18:55Z")

</div>

Thank you! This makes sense.

I guess Julia _does_ have concrete subtyping. `DataType` is a concrete type, and `Type{Int}` is a subtype. The tricky/impossible thing to do efficiently and what Julia lacks is to be able to define a new concrete type that subtypes an existing concrete type and has a different data layout.

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 27, 2024, 10:22pm UTC](https://discourse.julialang.org/t/are-int64-and-float64-of-the-same-type/113574/6 "2024-04-27T22:22:46Z")

</div>

well this one is also tricky and does cause all sorts of complications in the type system
