# How to test \`Int\` vs \`Int64\` correctness on my 64 bit development machine

**URL:** https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180
**Category:** Tooling
**Created:** [March 19, 2020, 10:01am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180 "2020-03-19T10:01:47Z")
**Posts on this page:** 8
**Page:** 1

<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: [March 19, 2020, 10:01am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/1 "2020-03-19T10:01:47Z")

</div>

Does anyone have any advice on how to test whether I’m using `Int` vs `Int64` correctly?

On 64-bit platforms like my laptop, `Int === Int64` so it won’t error out when I’m using `Int64` where I should use `Int` or vice-versa. I’m only testing 32 bit on my appveyor CI builds, and I’d like to be able to test correctness locally as well.

Concretely, I ran into issues with [`StatProfilerHTML`](https://github.com/tkluck/StatProfilerHTML.jl) using some of `Profile`’s data structures. I ended up with reading the source code, trial and error (which is slow on CI), and replacing with `<: Unsigned` where possible. I’m sure there’s a better way?

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 19, 2020, 10:20am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/2 "2020-03-19T10:20:16Z")

</div>

> [@tkluck](#):
>
> whether I’m using `Int` vs `Int64` correctly?

It is not clear what you mean here.

Do you want to check that you are on a 64-bit platform?

Or unit test your code for 32-bit platforms using CI running on 64-bit ones?

---

<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: [March 19, 2020, 10:33am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/3 "2020-03-19T10:33:24Z")

</div>

> [@Tamas\_Papp](#):
>
> Do you want to check that you are on a 64-bit platform?

This one is just `Int === Int64` no?

> [@Tamas\_Papp](#):
>
> Or unit test your code for 32-bit platforms using CI running on 64-bit ones?

If I understand you correctly, this is the one I mean. Given the availability of an M-bit platform, I want to test whether my code will work on N bit platforms for (possibly) N \neq M.

In practice, when M = 64, this mostly comes down to a correct usage of `::Int` vs `::Int64` in method signatures, or `::Vector{Int}` vs `::Vector{Int64}`. That’s where I got the title of this topic.

In many cases, `::Integer` or `Vector{<:Integer}` is more correct anyway, but not all. In particular, I don’t always control the method signatures I’m using. For example, `Profile` uses [Vector{UInt}](https://github.com/JuliaLang/julia/blob/f5afdf9/stdlib/Profile/src/Profile.jl#L382) and [Vector{UInt64}](https://github.com/JuliaLang/julia/blob/f5afdf9/stdlib/Profile/src/Profile.jl#L610) interchangeably. It probably shouldn’t (and that’s a bug I will report), but in the mean time I’ll have to work around it. I’d like to test locally ~~CI to reflect~~ whether those workarounds are successful.

Does that make sense?

edit: I mentioned CI where I should have said “locally”. That caused confusion.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 19, 2020, 11:08am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/4 "2020-03-19T11:08:00Z")

</div>

> [@tkluck](#):
>
> Given the availability of an MM -bit platform, I want to test whether my code will work on NN bit platforms for (possibly) N≠M

I am not sure why you would expect it _not_ to work in most cases. 32-bit platforms also have `Int64`.

The only thing I can think of is defining some methods too restrictively, eg with `Int64` where `Int` would be the correct one. You can test _some_ of these by calling them with `Int32` inputs, but some will come from native methods (array indexes etc) so this could be tricky.

For a comprehensive solution, I would just run CI in both 32- and 64-bit environments.

For a quick check, you can grep the code for `Int64`.

---

<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: [March 19, 2020, 11:18am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/5 "2020-03-19T11:18:03Z")

</div>

Thanks for trying to help, but it looks like I’m a few steps ahead here. I’m applying all those steps and indeed I’m running CI in 32 and 64 bit scenarios.

Now the problem is that things that are _only_ tested in CI have a very slow feedback loop, and that’s what [I’m targeting for improvement](https://lethain.com/feedback-loops-in-software-development/) in this topic. Apologies if I wasn’t clear about that from the start.

edit: I wasn’t clear about that, and edited one of the posts accordingly.

---

<div class="post-metadata">

### Author: ![c42f](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/c42f/32/52842_2.png) [@c42f](https://discourse.julialang.org/u/c42f)
#### Post date: [March 19, 2020, 11:30am UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/6 "2020-03-19T11:30:04Z")

</div>

Downloading the 32 bit build but running on your 64 bit machine should do the trick? Then you should have `Int === Int32`.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [March 19, 2020, 12:02pm UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/7 "2020-03-19T12:02:19Z")

</div>

> [@tkluck](#):
>
> things that are _only_ tested in CI have a very slow feedback loop

I believe that you can just build a 32-bit binary on a 64-bit platform if you want to run tests locally. See eg [https://github.com/JuliaLang/julia/blob/master/doc/build/linux.md#architecture-customization](https://github.com/JuliaLang/julia/blob/master/doc/build/linux.md#architecture-customization) or similar sections for other platforms.

---

<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: [March 19, 2020, 12:04pm UTC](https://discourse.julialang.org/t/how-to-test-int-vs-int64-correctness-on-my-64-bit-development-machine/36180/8 "2020-03-19T12:04:18Z")

</div>

Thanks @c42f and @Tamas_Papp! That’s what I was looking for. Will mark Chris’ post as the solution because I unfortunately have to choose one.
