I created some binary data using the php function pack
.
Then I needed to unpack this data from a java application. I've been able of unpacking integers, strings, longs and other data types but I'm in trouble with floats.
I create the data from php using a code like the following
pack("f", 189.0);
then in java i'm using the method readFloat()
from a DataInputStream
object, but i get small and incoherent values.
Apparently php and java uses different notations to represent floats. How can I solve this issue and perform a conversion from php packed float to native java float?