# Deprecated warning with round.(Int64,x)

**URL:** <https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 14, 2017, 2:28pm UTC](https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067 "2017-11-14T14:28:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zygmuntszpak](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zygmuntszpak/32/2591_2.png) [@zygmuntszpak](https://discourse.julialang.org/u/zygmuntszpak)\
**Post date:** [November 14, 2017, 2:28pm UTC](https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067/1 "2017-11-14T14:28:54Z")

</div>

I have a type `Array{Array{Float64,1},1}` which I would like to round and convert to Int64. However, when I attempt to do this I get a deprecated warning which I don’t understand. I don’t understand the difference between what it says is deprecated, and what it is asking me to do. I’d appreciate any advice on how to do the conversion as simply as possible. I am using Version 0.6.0 (2017-06-19 13:05 UTC) on x86\_64-w64-mingw32. I’ve provided a minimal example below.

Many thanks for your time.

```julia
julia> round.(Int64,Vector(Array{Float64,1}[[389.24, 0.0], [0.0, 292.22]]))
WARNING: round{T}(::Type{T}, x::AbstractArray) is deprecated, use round.(T, x) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at .\deprecated.jl:70
 [2] round(::Type{Int64}, ::Array{Float64,1}) at .\deprecated.jl:57
 [3] macro expansion at .\broadcast.jl:153 [inlined]
 [4] macro expansion at .\simdloop.jl:73 [inlined]
 [5] macro expansion at .\broadcast.jl:147 [inlined]
 [6] _broadcast!(::Base.#round, ::Array{Array{Int64,1},1}, ::Tuple{Tuple{},Tuple{Bool}}, ::Tuple{Tuple{},Tuple{Int64}}, ::Type{Int64}, ::Tuple{Array{Array{Float64,1},1}}, ::Type{Val{1}}, ::CartesianRange{CartesianIndex{1}}) at .\broadcast.jl:139
 [7] broadcast_t(::Function, ::Type{T} where T, ::Tuple{Base.OneTo{Int64}}, ::CartesianRange{CartesianIndex{1}}, ::Type{T} where T, ::Array{Array{Float64,1},1}) at .\broadcast.jl:268
 [8] broadcast_c(::Function, ::Type{Array}, ::Type{T} where T, ::Array{Array{Float64,1},1}, ::Vararg{Array{Array{Float64,1},1},N} where N) at .\broadcast.jl:314
 [9] broadcast(::Function, ::Type{T} where T, ::Array{Array{Float64,1},1}) at .\broadcast.jl:434
 [10] eval(::Module, ::Any) at .\boot.jl:235
 [11] eval_user_input(::Any, ::Base.REPL.REPLBackend) at .\REPL.jl:66
 [12] macro expansion at .\REPL.jl:97 [inlined]
 [13] (::Base.REPL.##1#2{Base.REPL.REPLBackend})() at .\event.jl:73
while loading no file, in expression starting on line 0
2-element Array{Array{Int64,1},1}:
 [389, 0]
 [0, 292]

julia> typeof(Vector(Array{Float64,1}[[389.24, 0.0], [0.0, 292.22]]))
Array{Array{Float64,1},1}

```

---

<div class="post-metadata">

**Author:** ![cdsousa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cdsousa/32/215553_2.png) [@cdsousa](https://discourse.julialang.org/u/cdsousa)\
**Post date:** [November 14, 2017, 2:38pm UTC](https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067/2 "2017-11-14T14:38:39Z")

</div>

~~I don’t know exactly the reason for the warning, but by simplifying your code to~~

```julia
round.(Int64,[[389.24, 0.0], [0.0, 292.22]])

```

(which is equivalent and easier to reason about)  
~~throws the warning away.~~

Edit:  
Sorry, forget what I wrote. The warning went away after a second run, not because the code was different.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 14, 2017, 2:38pm UTC](https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067/3 "2017-11-14T14:38:59Z")

</div>

You are still applying `round(Int64, ...)` on each element of the array so you should do that manually. Sth like `[round.(Int64, v) for v in ...]`

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [November 14, 2017, 3:56pm UTC](https://discourse.julialang.org/t/deprecated-warning-with-round-int64-x/7067/4 "2017-11-14T15:56:31Z")

</div>

As already noted the problem is that you need to dot broadcast a level deeper than you do. Actually doing it with two levels of dot broadcast is probably less readable than a comprehension but may give some additional insights into the problem.

```julia
julia> x = [[389.24,0.0],[0.0, 292.22]]
2-element Array{Array{Float64,1},1}:
 [389.24, 0.0]
 [0.0, 292.22]

julia> (t -> round.(Int, t)).(x)
2-element Array{Array{Int64,1},1}:
 [389, 0]
 [0, 292]

```
