# How to allow Float64 or ForwardDiff.dual in structs and arrays

**URL:** <https://discourse.julialang.org/t/how-to-allow-float64-or-forwarddiff-dual-in-structs-and-arrays/61521>\
**Category:** General Usage\
**Tags:** question\
**Created:** [May 20, 2021, 2:56pm UTC](https://discourse.julialang.org/t/how-to-allow-float64-or-forwarddiff-dual-in-structs-and-arrays/61521 "2021-05-20T14:56:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [May 20, 2021, 2:56pm UTC](https://discourse.julialang.org/t/how-to-allow-float64-or-forwarddiff-dual-in-structs-and-arrays/61521/1 "2021-05-20T14:56:42Z")

</div>

Hello,

I have a module that usually operates on Float64 types, but I also sometimes want to allow dual numbers for some initial optimization. How can I achieve that?

For example:

Now:

```julia
const SimFloat = Float64
const Vec3 = MVector{3, SimFloat} 

```

Better:

```julia
Dual1=ForwardDiff.Dual
const SimFloat = Union{Dual1, Float64}
const Vec3 = MVector{3, SimFloat}

```

What is the impact on the performance if I use a Union in structs and MVectors?
