Shop OBEX P1 Docs P2 Docs Learn Events
converting seperate word variables into one workable variable — Parallax Forums

converting seperate word variables into one workable variable

ilyailya Posts: 13
edited 2008-03-29 00:17 in BASIC Stamp
I am using a GPS unit to obtain position data. The data comes from the unit as two word variables, degrees and minutes. I need to combine these two variables into one variable. For example, if degrees=42 and minutes=4103 i need one variable, say position, to be 42.4103. Every time I try to divide minutes by 1000 to add it to degrees the minutes variable becomes 0000 because I assume that word variables cannot have decimals.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-26 22:04
    EME Systems' website has some excellent information on fixed point and multiple precision arithmetic with the Stamps. Look here www.emesystems.com under "app-notes". Because of the word size (16 bits), you cannot represent more than a little over 4 digits of information. You could have 360 degrees and two digits of minutes represented in 16 bits, but not more precision and it would be as an integer. You can have a fixed scale factor like 100, but your program has to do it by itself. The Stamp compiler/interpreter won't do it for you.
  • ilyailya Posts: 13
    edited 2008-03-29 00:17
    What do you mean by fixed scale factor of 100?
Sign In or Register to comment.