On Apr 6, 10:10 am, Byron <B...@discussions.microsoft.comwrote:
An example of a hex value I've encountered is:
414BFCC90D2258ED
This is 64 bit double precision floating point representation for a
cartesian coordinate system as used in Distributed Interactive Simulation
(DIS) (from IEEE 1278.1).
http://www.sisostds.org/dis%2Ddd/pdu/19.htm
Telling us what the correct interpretation of this string is would
help a lot. Also, notice that the data dictionary references doubles;
the string above is (presumably) a double encoded as a hex string.
Not the same thing.
I gave it a shot, though:
string hex = "414BFCC90D2258ED";
byte[] b = new byte[hex.Length / 2];
for (int i = (hex.Length - 2), j = 0; i >= 0; i -= 2, j++ )
{
b[j] = byte.Parse(hex.Substring(i, 2),
System.Globalization.NumberStyles.HexNumber);
}
double d = BitConverter.ToDouble(b, 0);
The value produced here is 3668370.1026107, which interpreted as
meters, is about 3700 kilometers. That sounds about right for Earth-
sized measurements. Notice that I'm walking through the string
backwards, thus treating it as little-endian (I hope I've remembered
my endian logic correctly). Treating it as big-endian gave me a very,
very small number.
Michael