I have this snippet with a strange result (279.1... vs. 279.6...):
$ perl -e "print unpack('f>', pack ('f>', 279.117156982422));"
279.617156982422
While this one works
$ perl -e "print unpack('f>', pack ('f>', 279.117256982422));"
279.117248535156
And those ones as well
$ perl -e "print unpack('f<', pack ('f<', 279.117156982422));"
279.11715698242
$ perl -e "print unpack('f', pack ('f', 279.117156982422));"
279.117156982422
What's wrong? Is that a bug in unpacking of non-native endian floating point values?
Note Perl is version 5.14.2 under Cygwin on a PC.
This is a GCC problem.
cpan -t Acme::Study::SREZIC passes OK on my 32bit systems where the Perl binary is compiled with GCC 4.5.4 or 4.6.3 or 4.6.4 and does not pass on systems where the Perl binary is compiled with GCC 4.7.3 or 4.8.3
Definitely a bug in Perl's unpacking. It has difficulty in handling floats in the binary form xxxxyyFF
at least in a 32-bit platform, where 80 <= yy <= BF
. The packed result will become xxxxzzFF
, where zz = yy + 40
(all in hexadecimal). And this is not a problem of endianness, as you could see here:
$ perl -e "print unpack('H8', pack ('f', unpack('f', pack('H8', '000088ff'))));";
0000c8ff
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With