Bohdan Bessonov Bohdan Bessonov - 1 month ago 13
C++ Question

Best way to store coords: struct of uints or double?

I have geo coordinates in format N000.11.22.333 E444.55.66.777. Milliseconds are necessary for precision. I need to perform calculations like calculate coord given coord0, angle and distance. Sure I want to keep precision not less than milliseconds. This and other calculation algorithms often use trigonometric functions to get a result.
Which solution is better: 1) use struct that contains degrees, minutes, seconds and milliseconds as uints and overload operators for manipulate them; 2) use double type and convert coords to decimal view for calculations. As I think float type is not enough stable on these calculations.

Be used for qt 5.9 x64 project, msvc 2017, win platform only

Answer Source

Pick whichever is easiest (almost definitely a double). A double is more accurate than a ruler or a careful surveyor. Lots of navigation software uses a single 32-bit integer for lat and one for long.