bcquality/microsoft/knowledge/data-modeling/round-direction-symbols-use-magnitude.md
Jesper Schulz-Wedde 8f025ac679 Merge current main into development guidance
Reconcile the read-only guidance output with the machine-readable skill index,
adopt linked sample references required by bounded retrieval, and update the
guidance regression fixture for the retrieval helper dependency. Permit only
the known endpoint-DLP metadata stream during read-only evidence capture.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 638b66d2-9f06-4f60-8781-808709e1485c
2026-09-18 12:04:06 +02:00

1.5 KiB

bc-version domain keywords technologies countries application-area
all
data-modeling
round
rounding
direction
precision
negative-decimal
amount
al
w1
all

Round direction symbols follow magnitude, not mathematical ordering

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

Use the Round function