Converting byte array to an array of another primitive type


If I have a byte array generated from an array of Float64 numbers, how can I get back the array of Float64 numbers?


If it is generated by reinterpret a Float64 array, you can reinterpret it back. If it’s directly generated as a UInt8 array, you should either think about generating Float64 array directly, or create a Float64 array and copy the data over with unsafe_copy!.


Great reinterpret is what I was looking for. Thank you.


No you must not use reinterpret if the data is not generated as a Float64 array originally.


Yes I know the type of the original data.


The warning not to reinterpret to Float64 if the data wasn’t originally Float64 is new to me, can you elaborate?