# How to convert Any '5' to Int 5?

**URL:** https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562
**Category:** General Usage
**Created:** [October 19, 2017, 3:57pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562 "2017-10-19T15:57:21Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [October 19, 2017, 3:57pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/1 "2017-10-19T15:57:22Z")

</div>

how to convert Any ‘5’ to Int 5 ?  
now ‘5’ is converted to 53  
julia\> test  
11449238-element Array{Any,1}:  
‘5’  
‘1’  
‘1’  
‘1’  
‘1’  
‘1’  
‘2’  
‘2’

julia\> convert(Array{Int64},test)  
11449238-element Array{Int64,1}:  
53  
49  
49  
49  
49  
49  
50  
Paul

---

<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: [October 19, 2017, 4:02pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/2 "2017-10-19T16:02:56Z")

</div>

What you are doing is not convertion but parsing so, `parse.(Int, test)`.

Although actually since you have character instead of string you’ll need `test .- '0'`

---

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [October 19, 2017, 4:22pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/3 "2017-10-19T16:22:15Z")

</div>

Thianks. Nice in Julia 6 .0 but im using 5.0 …

> parse.(Int64, test)  
> ERROR: MethodError: no method matching size(::Type{Int64})  
> Closest candidates are:  
> size{N}(::Any, ::Integer, ::Integer, ::Integer…) at abstractarray.jl:48  
> size(::BitArray{1}) at bitarray.jl:39  
> size(::BitArray{1}, ::Any) at bitarray.jl:43  
> …  
> in broadcast\_shape(::Type{T}, ::Array{Any,1}) at .\broadcast.jl:31  
> in broadcast\_t(::Function, ::Type{Any}, ::Type{T}, ::Vararg{Any,N}) at  
> .\broadcast.jl:213  
> in broadcast(::Function, ::Type{T}, ::Array{Any,1}) at .\broadcast.jl:230

Paul

W dniu 2017-10-19 o 18:08, Yichao Yu pisze:

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [October 19, 2017, 6:04pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/4 "2017-10-19T18:04:36Z")

</div>

Use an array comprehension instead of the broadcast?

---

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [October 19, 2017, 6:38pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/5 "2017-10-19T18:38:34Z")

</div>

> [@yuyichao](#):
>
> parse.(Int, test)

Some ide for Juloa 5.0 ?  
Paul

---

<div class="post-metadata">

### Author: ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)
#### Post date: [October 19, 2017, 6:39pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/6 "2017-10-19T18:39:39Z")

</div>

> [@dpsanders](#):
>
> Use an array comprehension instead of the broadcast

plese show me 🙂

---

<div class="post-metadata">

### Author: ![ggggggggg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ggggggggg/32/265_2.png) [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)
#### Post date: [October 19, 2017, 6:41pm UTC](https://discourse.julialang.org/t/how-to-convert-any-5-to-int-5/6562/7 "2017-10-19T18:41:34Z")

</div>

`[parse(Int,x) for x in test]`
