Skip to content

Fix activity route distance rounding parity - #1496

Merged
ryanbr merged 1 commit into
ryanbr:mainfrom
bhelm:codex/issue99-activity-route-distance-ulp
Aug 21, 2026
Merged

Fix activity route distance rounding parity#1496
ryanbr merged 1 commit into
ryanbr:mainfrom
bhelm:codex/issue99-activity-route-distance-ulp

Conversation

@bhelm

@bhelm bhelm commented Aug 20, 2026

Copy link
Copy Markdown

Summary

  • make Kotlin degree-to-radian conversion use the same multiply-then-divide operation order as Swift
  • preserve the earth radius, haversine expression, point order, and route accumulation order
  • add mirrored exact-bit tests for the reachable three-point route and an adjacent one-segment control

Root cause

Swift computes radians as x * pi / 180, while Kotlin used Math.toRadians, whose different intermediate rounding changes the second segment and final three-point distance by one binary64 ULP. Kotlin now spells out Swift's operation order; Swift production is unchanged.

Validation

  • RED before fix: the three-point Kotlin result was 0x403e89813f76c75d, while Swift and the independent oracle produced 0x403e89813f76c75c
  • frozen three-file diff is an exact semantic subset of the independently reviewed product-fix union
  • Swift exact focused tests: 2 passed
  • Swift affected StrandImport suite: 28 tests passed
  • Swift full StrandImport suite: 241 tests passed, 0 failures, 1 environment-dependent skip
  • Kotlin exact focused tests: 2 passed
  • Kotlin affected importer suite: 35 tests passed across the union's affected classes
  • Kotlin FullDebug: 4,157 tests passed, 0 failures/errors, 6 skipped
  • git diff --check: pass
  • independent static review: pass, no P0/P1/P2

Fixes bhelm#99.

@ryanbr
ryanbr merged commit 6345fb6 into ryanbr:main Aug 21, 2026
14 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.

[P2] Activity route distance differs by one ULP across Swift and Kotlin

2 participants