Is it possible to `reinterpret` a `UInt64` as `Array{UInt16,1}`

One can do

reinterpret(UInt64, rand(UInt16,4))

to convert an array of UInt64 into a UInt64 but if there a function to do a reverse of that? I tried

reinterpret(Array{UInt16,1}, rand(UInt64))

and it doesn’t work. I can do this manually using bitshifts, but I wonder if there is a function that does that already.

You could do reinterpret(UInt16, [rand(UInt64)]).

However, realize that the results of all of these operations depend on the endianness of the hardware, whereas a bitshift approach does not.

1 Like