In R, how do I convert a byte vector to IEEE-754 float (e.g. [0, 108, 4, 71] to 33900.0)?
In Ruby, I would do
[1191472128].pack("L").unpack("f") ==> 33900.0
I have tried the pack library: unpack("f", pack("V", 1191472128))
, but it returns 32795.06.
With using the package mcga
you can convert double types to byte vectors and vice versa:
> DoubleToBytes(33900.0)
[1] 0 0 0 0 128 141 224 64
and
> BytesToDouble(c(0,0,0,0,128,141,224,64))
[1] 33900
are the examples.