# \`reinterpret\` to a single value from an array of a smaller data type

**URL:** <https://discourse.julialang.org/t/reinterpret-to-a-single-value-from-an-array-of-a-smaller-data-type/9932>\
**Category:** General Usage\
**Created:** [March 23, 2018, 11:56pm UTC](https://discourse.julialang.org/t/reinterpret-to-a-single-value-from-an-array-of-a-smaller-data-type/9932 "2018-03-23T23:56:38Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![gdkrmr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdkrmr/32/2791_2.png) [@gdkrmr](https://discourse.julialang.org/u/gdkrmr)\
**Post date:** [March 24, 2018, 9:53am UTC](https://discourse.julialang.org/t/reinterpret-to-a-single-value-from-an-array-of-a-smaller-data-type/9932/12 "2018-03-24T09:53:27Z")

</div>

If you have a tuple of `UInt8`’s, the following gets completely optimized out for all Unsigned types:

> [@Type piracy?](https://discourse.julialang.org/t/type-piracy/9713/7):
>
> I was just toying around with this and found the following weird performance issue (Julia Version 0.7.0-DEV.4570): function f(::Type{UInt16}, x::NTuple{2, UInt8}) x1 = 0x0001 \* x[1] x2 = 0x0100 \* x[2] x1 + x2 end const NBytes{N} = NTuple{N, UInt8} function f(::Type{UInt16}, x::NBytes{2}) x1 = 0x0001 \* x[1] x2 = 0x0100 \* x[2] x1 + x2 end julia\> @btime f(UInt16, (0x01, 0x02)) 0.017 ns (0 allocations: 0 bytes) 0x0201 julia\> x = NBytes((0x01, 0x02)) (0x01, 0x02) julia\> …

I haven’t found a no op way to create byte tuples from `UIntX`.

---

_[View the full topic](https://discourse.julialang.org/t/reinterpret-to-a-single-value-from-an-array-of-a-smaller-data-type/9932)._
