wannaBinventor
Member
I'm working on some code (man has it been a work in progress) whereby a user can scroll through his GPS position and see it in Long/Lat, Universal Traverse Mercator, and Military Grid Reference System.
I was hung up on how to get the digraph letters for the MGRS, but I understand how to do that.
The problem is on the coding side.
The UTM easting is in float format because of all the trig I have to do to derive it. One of the things that I have to do to get the digraph is to divide the easting or northing by 100,000. When I divide the floating point easting by 100,000 and store it into a DWORD (32 bit unsigned variable) I'm noticing that it is rounding either up or down. I need it to ALWAYS round down.
I could convert the float to a string and then use the LEFT$ function to get the leading integer, but this seems unnecessary.
Any tips on this one? I'm using Amicus Basic, which is just the free limited version of Proton Basic.
Thanks!
I was hung up on how to get the digraph letters for the MGRS, but I understand how to do that.
The problem is on the coding side.
The UTM easting is in float format because of all the trig I have to do to derive it. One of the things that I have to do to get the digraph is to divide the easting or northing by 100,000. When I divide the floating point easting by 100,000 and store it into a DWORD (32 bit unsigned variable) I'm noticing that it is rounding either up or down. I need it to ALWAYS round down.
I could convert the float to a string and then use the LEFT$ function to get the leading integer, but this seems unnecessary.
Any tips on this one? I'm using Amicus Basic, which is just the free limited version of Proton Basic.
Code:
dim TEMP_DWORD as DWORD
dim LONG_DIGRAPH as DWORD
dim EASTING as FLOAT
.
.
more declarations and more code
.
.
'EXTRACT THE LONGITUDINAL DIGRAPH FOR MGRS
TEMP_DWORD = LONG_ZONE - 1 'subtract one from the long zone variable and store in dword long_digraph
TEMP_DWORD = (TEMP_DWORD // 3)
TEMP_DWORD = TEMP_DWORD * 8 'take the 3 modulus of this, multiply by 8
LONG_DIGRAPH = EASTING / 100000
LONG_DIGRAPH = LONG_DIGRAPH + TEMP_DWORD 'divide easting by 100,000 and then add value in temp_dword
Thanks!
Last edited: