# How to convert vectors and arrays from Float32 to Float64?

**URL:** <https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 12, 2021, 4:13pm UTC](https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393 "2021-11-12T16:13:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [November 12, 2021, 4:13pm UTC](https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393/1 "2021-11-12T16:13:22Z")

</div>

I have an Array A that is in Float32. My goal is to convert it from Float32 to Float64. I tried the below and neither of them worked:  
`B = float(A);`  
`B = convert(Float64, A)`

When I tried to check the type using typeof, it still shows Float32.

What should be the correct way to do the conversion? Many thanks!

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [November 12, 2021, 4:14pm UTC](https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393/2 "2021-11-12T16:14:46Z")

</div>

`Float64.(A)`. The difference is `Float64(A)` tries to convert the array to a `Float64` while the `.` broadcasts the operation to the elements of `A`.

---

<div class="post-metadata">

**Author:** ![leon](https://avatars.discourse-cdn.com/v4/letter/l/dc4da7/32.png) [@leon](https://discourse.julialang.org/u/leon)\
**Post date:** [November 12, 2021, 4:16pm UTC](https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393/3 "2021-11-12T16:16:02Z")

</div>

Got you! Many thanks for the quick solution 👍

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 12, 2021, 7:02pm UTC](https://discourse.julialang.org/t/how-to-convert-vectors-and-arrays-from-float32-to-float64/71393/4 "2021-11-12T19:02:50Z")

</div>

You can also use `convert` but with the “full type”:

```julia
julia> convert(Vector{Float64}, x_f32)
2-element Vector{Float64}:
 1.0
 2.0

julia> convert(Vector{Float64}, x_f64)
2-element Vector{Float64}:
 1.0
 2.0

```

The advantage over `Float64.(x)` is that it is a no-op if the data is already of the correct type:

```julia
julia> convert(Vector{Float64}, x_f64) === x_f64
true

```
