# How to parameterize an argument which is either Int64,Int32, etc

**URL:** <https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564>\
**Category:** General Usage\
**Created:** [July 5, 2020, 4:56pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564 "2020-07-05T16:56:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [July 5, 2020, 4:56pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564/1 "2020-07-05T16:56:20Z")

</div>

I tried this and it stubbornly refuses to accept anything but Int64:

```julia
function testint(num::Int)
    print(num)
end
check = Int8(4)

testint(check)

ERROR: MethodError: no method matching testint(::Int8)
Closest candidates are:
  testint(::Int64)

```

Obviously “arg::Int” is implicitly becoming “arg::Int64”.

---

<div class="post-metadata">

**Author:** ![mkarikom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkarikom/32/7096_2.png) [@mkarikom](https://discourse.julialang.org/u/mkarikom)\
**Post date:** [July 5, 2020, 5:01pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564/2 "2020-07-05T17:01:10Z")

</div>

Ok this works:

```julia
function testint(num::Integer)
    print(num)
end

```

---

<div class="post-metadata">

**Author:** ![Elrod](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elrod/32/22461_2.png) [@Elrod](https://discourse.julialang.org/u/Elrod)\
**Post date:** [July 5, 2020, 5:29pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564/3 "2020-07-05T17:29:09Z")

</div>

`Int === Int64` on 64 bit builds of Julia, while on 32-bit builds `Int === Int32`. That is, `Int` is concrete, aliasing the signed integer matching the Julia build type.  
`UInt` is the same way, but for unsigned integers.

---

<div class="post-metadata">

**Author:** ![tkluck](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkluck/32/15769_2.png) [@tkluck](https://discourse.julialang.org/u/tkluck)\
**Post date:** [July 5, 2020, 5:38pm UTC](https://discourse.julialang.org/t/how-to-parameterize-an-argument-which-is-either-int64-int32-etc/42564/4 "2020-07-05T17:38:21Z")

</div>

Looks like you found the answer yourself. Just in case this is useful next time, if you are trying to find an appropriate supertype, use `supertypes`. For example:

```julia
julia> supertypes(Int)
(Int64, Signed, Integer, Real, Number, Any)

```

This allows you to choose the most appropriate supertype for your function signature. Hope that helps!
