At 02:22 AM 1/5/2008 +0000, [EMAIL PROTECTED] wrote:
Since it is in little endian format so it becomes c057 05cc cccc ccdc
which is -92.09
... Since it is in little endian format so it becomes 4043 4ccc cccc ccdc
which is 38.60
I cant seem to figure out how is the conversion of HEX is done to X and Y
coordinates.
The Wikipedia article on IEEE floats is clear and contains some examples
(using single precision): http://en.wikipedia.org/wiki/IEEE_754 .
To do this manually:
(1) Separate the hex into the first three digits and the next 13,
as in c05 | 705ccccccccdc or 404 | 34cccccccccdc. The second parts are the
mantissae (which we may consider to be integers expressed in hexadecimal).
(2) Strip the initial binary digit from the initial three. You
don't have to do the binary conversion: just keep any initial 0, 1, ..., 7
as is and convert 8 --> 0, 9 --> 1, ..., f --> 7. If you have to convert,
the sign is negative. In the examples we obtain - | 405 and + | 404.
(3) Subtract 400H from the first three digits and add 1. In the
examples we have 405 - 400 + 1 = 6 and 404 - 400 + 1 = 5. These are the
exponents (in hexadecimal).
(4) The value equals [Sign] * 2^[exponent] * (1 +
[mantissa]/16^13). In the examples we have
-1 * 2^6 * (1 + 0.438916731) = -92.09067078
+1 * 2^5 * (1 + 0.206250715) = +38.60002289.
Using Excel functions Hex2Dec, Bin2Hex, Hex2Bin, and some string functions,
you can do this in a spreadsheet, which is helpful when you're
experimenting. One implementation is appended to this message: it spans
the range A1:C8, input is in cell B2, and output is in cell C2.
Best,
Bill Huber
Quantitative Decisions
NB: The last two lines of the spreadsheet are a kluge to work around a
limitation in Hex2Dec: it cannot process a 13 digit integer, so we break it
into a 6-digit and a 7-digit integer and convert them separately.
,Hex,Decimal
Value,c05705ccccccccdc,=C4*2^C5*C6
Sign+exponent,=LEFT(B2,3),=HEX2DEC(B3)
Sign,=IF(C4=-1,1,0),=IF(C3>=2048,-1,1)
Exponent,=SUBSTITUTE(B3,LEFT(B3,1),BIN2HEX(RIGHT(HEX2BIN(LEFT(B3,1)),3)),1),=IF(C4=-1,C3-2048,C3)-1023
Mantissa,=RIGHT(B2,13),=(C8/(16^6)+C7)/16^6+1
Mantissa1,=LEFT(B6,6),=HEX2DEC(B7)
Mantissa2,=RIGHT(B6,7),=HEX2DEC(B8)
_______________________________________________
Geowanking mailing list
[email protected]
http://lists.burri.to/mailman/listinfo/geowanking