Big-endian double is incorrect
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ghex (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: ghex
In big-endian mode, the calculation of the "64-bit float" display is broken, and actually calculates it using a middle-endian order... the 8 bytes are broken into two 4-byte words, and each word is read big-endian as requested, but the two words are then combined in a little-endian order.
In little-endian mode, the display is correct.
If the file reads 12 34 56 78 9A BC DE F0, for example, and you get it to read it as a double in little-endian format, then it correctly says "-4.886460e+235", which is the value that would be represented in a double as 0xF0DEBC9A78563412, ie that file correctly read in little-endian format.
However, reading that same file as big-endian, it should show 5.626349e-221, being the double represented by 0x123456789ABCD
For comparison, Python:
>>> struct.
(-4.88645965504
>>> struct.
(5.626349274901
>>> struct.
(-6.95764366109
This is with ghex package version 2.24.0-1, on Lucid 10.04.1 amd64.
Looks to be fixed at some point between 2010 and v. 3.6.0.
Big-endian display of "12 34 56 78 9A BC DE F0" is correctly interpreted as 5.626349e-221.