Skip to content

fix(extract): deterministic decisecond rounding in extraction + tests#7627

Open
DennisOSRM wants to merge 9 commits into
masterfrom
fix/deterministic-decisecond-rounding
Open

fix(extract): deterministic decisecond rounding in extraction + tests#7627
DennisOSRM wants to merge 9 commits into
masterfrom
fix/deterministic-decisecond-rounding

Conversation

@DennisOSRM

@DennisOSRM DennisOSRM commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Make decisecond rounding deterministic by using long double floor-based rounding when converting segment.duration to integer deciseconds. Add a focused unit test (unit_tests/util/rounding_consistency.cpp) to detect platform-dependent differences between std::round on double and a long double floor-based rounding. Revert temporary JS fuzzy-tolerance change.

This PR aims to remove flaky 0.1s differences observed on Ubuntu 26.04 CI by ensuring deterministic rounding behavior across platforms.

CI confirms the fix, the debug logging added earlier will be removed.

DennisOSRM and others added 5 commits June 19, 2026 13:50
…t to detect platform rounding differences

- Use long double floor-based rounding when converting segment.duration to integer deciseconds to avoid platform-dependent std::round behavior.
- Add unit_tests/util/rounding_consistency.cpp to catch rounding mismatches between double std::round and long double floor method.
- Revert temporary JavaScript fuzzy-tolerance test change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 20, 2026 09:28
@DennisOSRM DennisOSRM changed the title Deterministic decisecond rounding in extraction + tests fix(extract): deterministic decisecond rounding in extraction + tests Jun 20, 2026

This comment was marked as outdated.

@DennisOSRM DennisOSRM changed the base branch from master to chore/upgrade_ci_pipeline June 21, 2026 15:28
The long double + floor approach preserves binary representation errors
of decimal fractions, causing incorrect rounding for values like 1.45
(rounds to 14 deciseconds instead of the correct 15).

IEEE 754 double-precision correctly-rounded multiplication compensates
for these errors: 1.45*10.0 snaps to exactly 14.5, and std::round(14.5)=15.

The std::round approach is deterministic on all modern platforms
(FLT_EVAL_METHOD=0 on x86-64 and ARM).

Replaced the unit test that compared two inherently different rounding
methods with proper tests that validate correct concrete decisecond
values and verify determinism.
@DennisOSRM DennisOSRM changed the base branch from chore/upgrade_ci_pipeline to master June 21, 2026 15:38
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