how to convert bytes to some...

A

asazykin

help need.... trying to convert binary file bytes 188-189 hav latitude
values.
how can i get from hex a6d4 - decodec to 217.200000
any ideas????would appreciate.....
 
W

Walter Roberson

help need.... trying to convert binary file bytes 188-189 hav latitude
values.
how can i get from hex a6d4 - decodec to 217.200000
any ideas????would appreciate.....

That's probably an algorithms question rather than a C question.
The number you gave is only 16 bits, so if it is a floating point
format then it is an unusual format, possibly a standard within
that particular industry but not widely used.

It may be a coincidence that if you take the first byte, 0xa6,
and subtract off a bias constant of 0x80 (representing the centre
lattitude, 180), then you get a result of 38, which is the round
up of (217.2 - 180).

Are you certain that those bytes alone give the lattitude?
For example if you are working with GPS, then you would use a 2 byte
offset relative to a 4 byte reference lattitude.
http://www.cse.unsw.edu.au/~emnet/EMNET2004/slides/WalkingGPS-EmNetS 2004 Presentation.pdf
 
A

asazykin

thanx for the reply ...
sorry my mistake this is not a latitude this is altitude...
with lat and long i didnt have any problem they were stored in integer
format....
problem is altitude.
 
W

Walter Roberson

thanx for the reply ...

Please quote enough context so that people can follow along.
sorry my mistake this is not a latitude this is altitude...
with lat and long i didnt have any problem they were stored in integer
format....
problem is altitude.

We would need a few more examples, and an indication of units
might help. Are there minimums and maximums? Is the maximum
about 333? Or about 262? Any hints on the resolution? Is it
pausible that "nautical" measurements are involved in storage but
not in the display (or the other way around)?

If you take 0xa6d4, swap the bytes around to get 0xd4a6, and
subtract off 0x8000, the result is 21670 which is 99.769797
times the output value you are expecting. A conversion
of units with a value very close to 1.00 could account for the
residue.

But one sample isn't enough to go on. (And this isn't really the
right newsgroup, since the matter is not C specific.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top