# Automatic conversion Int64 -\>Float64 for Unions

**URL:** <https://discourse.julialang.org/t/automatic-conversion-int64-float64-for-unions/56071>\
**Category:** Internals & Design\
**Created:** [February 26, 2021, 8:53am UTC](https://discourse.julialang.org/t/automatic-conversion-int64-float64-for-unions/56071 "2021-02-26T08:53:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sylvaticus](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaticus/32/203883_2.png) [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Post date:** [February 26, 2021, 8:53am UTC](https://discourse.julialang.org/t/automatic-conversion-int64-float64-for-unions/56071/1 "2021-02-26T08:53:52Z")

</div>

Currently integers to floats “automatic” conversion is successful only if the type is not a Union but it fails otherwise:

```julia
a = Float64[1.0,2.0]
a = Float64[1,2] # ok

a = Union{Float64,String}[1.0,"aaa"]
a = Union{Float64,String}[1,"aaa"] # MethodError

```

From a user-centric point of view, is there a way that integer to float could be handled automatically even in cases of Unions without ambiguity or performance losses ?

---

<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:** [February 26, 2021, 3:00pm UTC](https://discourse.julialang.org/t/automatic-conversion-int64-float64-for-unions/56071/2 "2021-02-26T15:00:27Z")

</div>

I don’t think this is possible automatically. If the union was `Union{Int32, Float64}` what does `Int` convert to?
