Converting byte array to an array of another primitive type


#1

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


#2

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!.


#3

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


#4

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


#5

Yes I know the type of the original data.


#6

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


#7