Skip to content

[Bug] BDS 6,0 magnetic heading: positive branch integer division loses 90/512° LSB #82

Description

@willi-werner

Classification: Bug (standards-compliance audit)

HeadingAndSpeed.computeMagneticHeading() uses integer arithmetic in the positive (non-sign) branch: value * 90 / 512. value, 90 and 512 are all integral, so the result is truncated to whole degrees, discarding the standard LSB of 90/512 deg (~0.176 deg). e.g. value=300 yields 300*90/512 = 52 deg instead of 52.73 deg. The negative branch uses (-Math.pow(2,10)+value)*90/512 which is double-precision and correct; the resulting asymmetry (only positive headings truncated) confirms this is an unintended integer-division defect, not a deliberate rounding.

  • Code reference: msgs/bds/HeadingAndSpeed.java:computeMagneticHeading():183 @ 94df15f
  • Standard: ICAO Doc 9871 (1st ed.) Table A-2-96 (BDS code 6,0 Heading and speed report; MAGNETIC HEADING MSB=90 deg, LSB=90/512 deg, range [-180,+180]) p.92; DO-181E Register 60 magnetic-heading worked example Table 13.a(1) p.514

Proposed fix: Use float arithmetic in the positive branch: value * 90F / 512 (matching the double-precision negative branch), so both signs preserve the 90/512-degree resolution.


Filed by the automated lib1090 standards-compliance audit (run 20260715T182455Z, subject commit 94df15f, version 5.0.0-SNAPSHOT). Finding LIB1090-012. Verified against DO-260B / DO-181E / ICAO Doc 9871.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions