473,320 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Hex to Float conversion of GPS Latitude


I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

Thanks in advance

Vadim

Nov 10 '06 #1
13 8758
On 10 Nov 2006 14:31:45 -0800, vo*****@hotmail.com wrote in
comp.lang.c:
>
I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

Thanks in advance

Vadim
Did you have a question about the C language?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~a...FAQ-acllc.html
Nov 11 '06 #2
Did you have a question about the C language?

I can teach C :)

.... just thought C-people are the most qualified for my question (since
the population of Assembler-people sharply diminished)
Someone just might find this question a brain-teaser and give it a
try...

Nov 11 '06 #3
On 2006-11-11, vo*****@hotmail.com <vo*****@hotmail.comwrote:
>Did you have a question about the C language?

I can teach C :)

... just thought C-people are the most qualified for my question (since
the population of Assembler-people sharply diminished)
Someone just might find this question a brain-teaser and give it a
try...
The folks at sci.crypt would be better suited to decoding. They
hate "brainteasers" like this though, so you might not have such
great luck. (The fact that it's pretty well-defined, unlike
"decode XXXXXXXXXXXXXX into a common saying", will likely help
you.)
Nov 11 '06 #4
vo*****@hotmail.com said:
>Did you have a question about the C language?

I can teach C :)
Oh, so it's *your* fault, is it? Come over here a minute...

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: normal service will be restored as soon as possible. Please do not
adjust your email clients.
Nov 11 '06 #5

vo*****@hotmail.com wrote:
I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

Thanks in advance

Vadim
You should look at test cases using numbers such as:
0.0
1.0
2.0
4.0
8.0
32767.0
10
100
1000
10000
and the pattern of encoding in the 4-bytes should become apparent.

- mkaras

Nov 11 '06 #6
You should look at test cases using numbers such as:
0.0
1.0
2.0
4.0
8.0
32767.0
10
100
1000
10000
and the pattern of encoding in the 4-bytes should become apparent.
.... if I had a coder, ... but all I have is data:
http://sonyaexpress.com/track_log.jpg

Nov 11 '06 #7
In article <11**********************@h48g2000cwc.googlegroups .com>,
<vo*****@hotmail.comwrote:
>... if I had a coder, ... but all I have is data:
http://sonyaexpress.com/track_log.jpg
Based upon that data, it appears that the GPS encoding is linear.
The top bit in each byte pair is not used for some reason, so
form a number as ((first hex byte pair * 2^16 / 2) + second hex byte pair).
A change of 120 (decimal) in that number represents a change of .0001
degree.

The encoding appears to be 2's complement (a smaller hex longitude is
more negative decimal). My guess is that 7FFF7FFF would encode the
least negative number, (-1/(120*1000)) degree, and that either
4000000 or 4000001 would encode the most negative, 1/(120*1000) more than
-180 degree.

I have not worked out the conversion to absolute coordinates, just
the relative changes.

The key entries to look at are #1 and #18: #1 is the most north-east
and #18 is the most south-west. That gives you the longest baseline
for finding the relative change between hex and decimal.

There is some uncertainty in the 120 figure, by about +/- 0.1
which is close enough to say "It wouldn't make any sense for them
to encode in multiples of 119.82 thousands of a degree" and so
Occamize the figure to 120 exactly.
--
If you lie to the compiler, it will get its revenge. -- Henry Spencer
Nov 11 '06 #8
In article <11**********************@h48g2000cwc.googlegroups .com>,
<vo*****@hotmail.comwrote:
>... if I had a coder, ... but all I have is data:
http://sonyaexpress.com/track_log.jpg
If you go to the page above that one and look down to the last link,
you will see "Powered by Ontime Mobile". If you click on that,
the page that brings up indicates that OnTime Mobile
"Runs on all GPS-enabled Nextel/Motorola phones"

Reading around a bit, it appears there are literally dozens of different
GPS file formats in use. If you chase documentation for the Motorola
iDen line with GPS, you might be able to hunt down something relevant.

It is possible, though, that the file format in use is proprietary:
they could be calculating the locations based upon the GPS data and
storing those in their own private format.

I looked around a bit but did not manage to dig out the relevant
information out of (too many) pages. I did find a large resource
sight that has too many links for me to read through at this time:
http://gpsinformation.net/
--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson
Nov 11 '06 #9
vo*****@hotmail.com wrote:
I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

http://sonyaexpress.com/track_log.jpg
The high bit in each byte is unused. Removing these four bits and
splicing together the remaining bits produces a 28-bit integer equal to
the number of degrees * 600000. Negative values are represented using
two's complement.

If code[] contains the four bytes in left to right order,

c = code[ 0 ] << 21 |
code[ 1 ] << 14 |
code[ 2 ] << 7 |
code[ 3 ];
if ( c & 0x8000000 )
c -= 0x10000000;
degrees = c / 600000.0;

- Ernie http://home.comcast.net/~erniew

Nov 12 '06 #10

Walter,

Thank You very much for trying to solve this riddle.
I am a founder of OnTime Mobile. But this track log is unrelated to the
core business of the company. I'm experimenting with GPS data logger
and that's how it stores data.

Nov 12 '06 #11

Ernie Wright wrote:
vo*****@hotmail.com wrote:
I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

http://sonyaexpress.com/track_log.jpg

The high bit in each byte is unused. Removing these four bits and
splicing together the remaining bits produces a 28-bit integer equal to
the number of degrees * 600000. Negative values are represented using
two's complement.

If code[] contains the four bytes in left to right order,

c = code[ 0 ] << 21 |
code[ 1 ] << 14 |
code[ 2 ] << 7 |
code[ 3 ];
if ( c & 0x8000000 )
c -= 0x10000000;
degrees = c / 600000.0;

- Ernie http://home.comcast.net/~erniew
You can see the above ideas implemented at:

http://spreadsheets.google.com/ccc?k...XtLnNXkT5oaQQg

- mkaras

Nov 12 '06 #12
Ernie, mkaras

You guys are amazing... :)
Thank you very much.

Thanks a lot to all who spent time thinking about it.

I really appreciate it.

As I said in the beginning of the thread: C-people rule!

I also posted this question on sat-nav, math and crypt forums, and
C-people, ... I said it already :)

Case is closed!

Cheers

Nov 12 '06 #13
Ernie Wright wrote:
vo*****@hotmail.com wrote:
>I would really appreciate if someone could give me a hint
how these floats are encoded:

0B7D2F70 41.8713
0B7D232F 41.8687
0B7D220F 41.8684

http://sonyaexpress.com/track_log.jpg

The high bit in each byte is unused. Removing these four bits and
splicing together the remaining bits produces a 28-bit integer equal to
the number of degrees * 600000. Negative values are represented using
two's complement.

If code[] contains the four bytes in left to right order,

c = code[ 0 ] << 21 |
code[ 1 ] << 14 |
code[ 2 ] << 7 |
code[ 3 ];
if ( c & 0x8000000 )
c -= 0x10000000;
degrees = c / 600000.0;
Very good. Here's another formulation:

#include <stdio.h>

float val(unsigned long x)
{
unsigned long b = (((x >24) & 0x7F) << 21)
| (((x >16) & 0x7F) << 14)
| (((x >8) & 0x7F) << 7)
| (x & 0x7F);
if (b & 0x8000000) b -= 0x10000000;
return b / 600000.0;
}

int main(void)
{
printf("%.4f\n", val(0x0B7D2F70));
printf("%.4f\n", val(0x0B7D232F));
printf("%.4f\n", val(0x0B7D220F));
return 0;
}

--
Simon.
Nov 13 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jim West | last post by:
Both int a; std::complex<float> b; std::complex<float> c = static_cast<float>(a)*b; and int a; std::complex<float> b;
14
by: Glen Able | last post by:
Should it be possible to create a custom class, 'Float', which would behave as a drop-in replacement for the builtin float type? As mentioned in another thread, I once tried this in rather a...
54
by: Andy | last post by:
Hi, I don't know if this is the correct group to post this, but when I multiply a huge floating point value by a really small (non-zero) floating point value, I get 0 (zero) for the result. This...
1
by: Bruno van Dooren | last post by:
Hi, i have a simple question that has bothered me for some time now. if i have a function foo( double a) and i do something like float b = 2.0; foo(b);
6
by: karthi | last post by:
hi, I need user defined function that converts string to float in c. since the library function atof and strtod occupies large space in my processor memory I can't use it in my code. regards,...
16
by: Enekajmer | last post by:
Hi, 1 int main() 2 { 3 float a = 17.5; 4 printf("%d\n", a); 5 printf("%d\n", *(int *)&a); 6 return 0; 7 }
15
by: k3n3dy | last post by:
Hello everybody, I would like to ask anybody to help me understand what should be done exactly with this Problem. I have provided what I have up to now, although it is not quite accurate. Create...
14
by: Jim Langston | last post by:
The output of the following program is: 1.#INF 1 But: 1.#INF 1.#INF was expected and desired. How can I read a value of infinity from a stream?
8
by: d major | last post by:
I was very puzzled about the conversion between float and long, I cann't understand why a long val can convert to a float, as the below codes show: typedef unsigned long u_long; float val =...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.