#How to read float from byte array

1 messages · Page 1 of 1 (latest)

marsh raft
#

Hello, I see there is std.mem.readInt but no readFloat, what is the right way to read a float from a byte array?

subtle lance
#

you could cast a *const [8]u8 pointer to a *align(1) const f64 and dereference that - do make sure though your bytes are ordered the right way to create the wanted float - endianness means you might get unexpected results if you aren't careful!

hot sinew
#

i would just use readInt and bitcast the result

subtle lance
#

also possible