`Round` direction symbols follow magnitude, not mathematical ordering
AL's Round(Number, Precision, Direction) uses '>' to round away from zero and '<' to round toward zero. For a negative value this reverses mathematical ordering: Round(-1234.56789, 0.001, '<') returns -1234.567, while direction '>' returns -1234.568.
- microsoftlayer
- data-modelingdomain
- 2examples
- 2pull requests
Rule on GitHub · microsoft layer · data-modeling · BC all · tier official · derived
Description
AL’s Round(Number, Precision, Direction) uses '>' to round away from zero and '<' to round toward zero. For a negative value this reverses mathematical ordering: Round(-1234.56789, 0.001, '<') returns -1234.567, while direction '>' returns -1234.568. Code that treats the symbols as mathematical ceiling and floor produces sign-dependent amount errors, commonly on credit documents and negative adjustments.
Best Practice
Choose the direction from the business meaning: '>' increases absolute magnitude and '<' decreases absolute magnitude for both positive and negative values. Include positive and negative cases whenever a directed rounding rule is tested.
See sample: round-direction-symbols-use-magnitude.good.al.
Anti Pattern
Using '<' as a mathematical floor or '>' as a mathematical ceiling. The result looks correct for positive amounts but moves in the opposite mathematical direction for negative amounts.
See sample: round-direction-symbols-use-magnitude.bad.al.
Reference
Examples
- Good: round-direction-symbols-use-magnitude.good.al
- Bad: round-direction-symbols-use-magnitude.bad.al
Changed by
- #195 Add foundational AL developer knowledge, 2026-09-21
- #57 Add source-verified Finance knowledge and review domain, 2026-09-21
From microsoft/BCQuality at a4593a1, MIT License, Copyright (c) 2026 Microsoft Corporation (license).