Greetings

I am developing a database of GPS Coordinates for use in Aviation. During the course of my activities, I have gathered a considerable number of waypoints which, naturally enough, are most easily manipulated in the digital coordinate format of DD.dddddd. All of my waypoints are recorded in that format. However, in some circumstances, it is necessary that the coordinates be reported in DD MM.mmm -and therein lies the rub. I have successfully got my coordinates reporting N/S E/W within a calculated field, using (If ( LATITUDE>0 ; "N" ; "S" )) etc., but I'm having real trouble getting my head around how to do the rest! The mathermatics are easy... the whole degrees stay as whole degrees, everything after the decimal is multiplied by 60 to provide the MM.mmmm -it's just the getting there that I am having trouble with. How do I extract just the whole degrees from the coordinates, without rounding? How best do I extract only the information after the decimal so I can do the multiplication to provide the result I'm after?

Of course, it would be tremendous if there was a way to convert coordinates bi-directionally! For the meantime though, I would appreciate any assistance offered to crack the immediate problem.

Best regards

RS

Good catch! I'd say that's pretty important. The quick-and-dirty off-the-top-of-my-head solution is to detect negative values at the start and convert the math to positive. It feels like there ought to be a more straightforward way, but I need to get back to work.

Let ( [

~original = -123.456 ;

~negative = ~original < 0 ; // True (1) if value is negative

~positive = Abs ( ~original ) ;

~degrees = Div ( ~positive ; 1 ) ;

~minutes = Mod ( ~positive ; 1 ) * 60 ;

~decimal = ~degrees + ~minutes / 60 ;

~decimal = If ( ~negative ; 0 - ~decimal ; /* Else */ ~decimal )

] ;

"Original: " & ~original

& ¶ & "Degrees-Minutes: "

& If ( ~negative ; "-" )

& ~degrees & "° " & ~minutes & "'"

& ¶ & "Decimal: " & ~decimal

)