-
Hello, I'm wondering how I can go about casting an array of four bytes into a Float32 in Mojo? Essentially, I'm trying to replicate some old Python code that looked like this: val, = struct.unpack(pack_format, data[pos:pos + data_size]) |
Beta Was this translation helpful? Give feedback.
Answered by
ericqu
May 13, 2024
Replies: 1 comment 1 reply
-
I am not sure if that is the intended way to do that; I am just trying things out. I used
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
jblindsay
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am not sure if that is the intended way to do that; I am just trying things out. I used
bitcast
and reused theSIMD
type to force a cast. To illustrate, I start from a Float32 to an array of uint8 (byte) and from that array back to a Float32.