According to this calculator site (link text), when converting 3 from decimal to double, I should get 4008 0000 0000 0000.
When using the Perl pack function, with the parameter “d>*”, I expected to see 4008 0000 0000 0000 as I use this function:
print $File pack("d>*", 3);
But when I “hexdump” to the Perl output file, I see 0840 0000 0000 0000.
I thought that it might belong to the big/little endian, but when trying the little endian,
print $File pack("d<*", 3);
I get this: 0000 0000 0000 4008
What shall I do if I want to get the result 4008 0000 0000 0000 from Perl pack output?
By the way, when using “float” – everything works like it is expected to be.
Your intuition about the byte order in Perl is correct, but I think that the hexdump output doesn’t mean what you think it does. It looks like hexdump is displaying each pair of bytes in a consistent but counterintuitive order. Here are some experiments you can run to get your bearings.