# Port C++ union to Julia

**URL:** <https://discourse.julialang.org/t/port-c-union-to-julia/950>\
**Category:** General Usage\
**Tags:** question\
**Created:** [December 14, 2016, 5:30pm UTC](https://discourse.julialang.org/t/port-c-union-to-julia/950 "2016-12-14T17:30:09Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [December 14, 2016, 5:54pm UTC](https://discourse.julialang.org/t/port-c-union-to-julia/950/2 "2016-12-14T17:54:22Z")

</div>

You can store it as `UInt64` and use `i64 % UInt32` to get a `UInt32` and `reinterpret(Float64, i64)` to get a `Float64`. Julia is type safe by default so it’s non-trivial to come up with a representation of C compatible `union`.

---

_[View the full topic](https://discourse.julialang.org/t/port-c-union-to-julia/950)._
