Skip to content

Fix rounding carry in DMM and DMS coordinates - #412

Merged
rnorris merged 1 commit into
viking-gps:masterfrom
emincan2000:dms-rounding-carry
Nov 25, 2026
Merged

rnorris merged 1 commit into
viking-gps:masterfrom
emincan2000:dms-rounding-carry

Conversation

@emincan2000

Copy link
Copy Markdown
Contributor

Viking can display 10.1 degrees north as N10°5'60.0000" in DMS mode instead of the expected N10°6'0.0000". The floating point value falls just below a minute boundary. The minutes have already been split off when the seconds round to 60. DMM can also display 60.000000 minutes for a value just below a whole degree.

The formatter now rounds minutes or seconds to the displayed precision before applying the carry. In DMS mode the seconds can carry into minutes and then into degrees. In DMM mode the minutes carry into degrees.

The degree conversion test checks the DMM and DMS strings for latitude and longitude at 10.1 and 51.3 degrees. It also covers a negative coordinate and a value just below a whole degree. An ordinary coordinate checks that the formatting still works when no carry is needed.

I built degrees_converters.c with the degrees_converter test program and ran check_degrees_conversions.sh. The new checks fail on the current code and pass with this change. The existing checks still pass. I also compared the old and new DMM and DMS strings for 3.6 million latitudes between -180 and 180. The output changed for only 404 of them. Every changed value used to show 60 seconds. No new output contains 60 minutes or seconds.

Round the last displayed component before carrying into minutes or degrees.
Add exact output checks to the degree conversion test.
@rnorris
rnorris merged commit c7a0af6 into viking-gps:master Nov 25, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants