I have a 32-bit integer. The bit stream is actually a bit stream for a 32-bit float (IEEE 754). I tried converting it with:
unpack('f', $input);
This generates a float, but it seems it is not the right number
For example, if I pass in 1, I should be coming out with 1.4012984e-45, according to the IEEE754 converter,
but I am coming with 2.5638762224389E-9
Thanks a lot for any help/advice.
You’re confusing things:
gives
array(1) { [1]=> float(1.4012984643248E-45) } array(1) { [1]=> float(2.5638762224389E-9) }According to the manual, these results are not guaranteed (the “f” modifier in
unpackwill depend on the endianness of the system). But one thing is a byte stream which has actually those values and other thing is to have a byte stream which happens to translate to “0001” when the ASCII charset is considered.