# Very strange language choice for printing integer vs float arrays

**URL:** <https://discourse.julialang.org/t/very-strange-language-choice-for-printing-integer-vs-float-arrays/84945>\
**Category:** General Usage\
**Tags:** question, input-output, io\
**Created:** [July 28, 2022, 10:12pm UTC](https://discourse.julialang.org/t/very-strange-language-choice-for-printing-integer-vs-float-arrays/84945 "2022-07-28T22:12:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![singularity](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@singularity](https://discourse.julialang.org/u/singularity)\
**Post date:** [July 28, 2022, 10:12pm UTC](https://discourse.julialang.org/t/very-strange-language-choice-for-printing-integer-vs-float-arrays/84945/1 "2022-07-28T22:12:45Z")

</div>

I find the following behavior of print statement quite strange.

Let’s say I have an array of floating point numbers and I print it. That is,

```julia
a = [2.0, 3.0]
println(a)

```

I get the following result upon executing the code above:

`[2.0, 3.0]`

However, if I do the same thing with an array of integers, I get this

```julia
b = convert.(Int32, a)
println(b)

```

This time I get the result

`Int32[2, 3]`

Why this inconsistency? Why is it showing the datatype now?

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [July 28, 2022, 10:18pm UTC](https://discourse.julialang.org/t/very-strange-language-choice-for-printing-integer-vs-float-arrays/84945/2 "2022-07-28T22:18:56Z")

</div>

try

`b = convert.(Int, a)`

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [July 28, 2022, 10:19pm UTC](https://discourse.julialang.org/t/very-strange-language-choice-for-printing-integer-vs-float-arrays/84945/3 "2022-07-28T22:19:38Z")

</div>

The unannotated array `[2, 3]` is reserved for `Int64` specifically, just like how `[2.0, 3.0]` is reserved for `Float64`. On the other hand, `println([2.0f0, 3.0f0])` prints `Float32[2.0, 3.0]`.

That type annotation is just syntax for specifying the element type of an array literal. It’s useful to write explicitly if Julia guesses wrong. For example, writing `[1.0, 1]` converts everything to `Float64` for performance reasons, but if I needed to keep the types as is, I would write `Real[1.0, 1]`.
