Skip to content

Carry rounded lengths into kilometres - #88

Open
machines-6657 wants to merge 1 commit into
xolox:masterfrom
machines-6657:codex/2026-10-12-format-length-carry
Open

machines-6657 wants to merge 1 commit into
xolox:masterfrom
machines-6657:codex/2026-10-12-format-length-carry

Conversation

@machines-6657

Copy link
Copy Markdown

Fix format_length() rounding into the next unit

Problem

format_length() chooses a unit before rounding its value to two decimal places. As a result, a supported length such as 999.999 metres is rendered as 1000 metres, even though the rounded quantity is exactly 1 km and that unit is supported.

Change

After rounding, carry into the next larger supported length unit when the rounded value reaches its divider. Add a regression assertion for the metre-to-kilometre boundary.

Validation

  • Regression test: fails before the fix (1000 metres instead of 1 km), passes after it.
  • Portable suite: 63 passed; six unrelated platform-dependent tests deselected.
  • Full suite: 63 passed, 6 failed on Windows due to missing HOME, hard-coded bash, and Unix-only termios dependencies.
  • flake8, Python compilation, and git diff --check pass.

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.

1 participant