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.
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.
msgs/bds/HeadingAndSpeed.java:computeMagneticHeading():183@94df15fProposed 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 commit94df15f, version5.0.0-SNAPSHOT). FindingLIB1090-012. Verified against DO-260B / DO-181E / ICAO Doc 9871.