Calculation procedures in AdvPL
Separates inputs, calculation rules and rounding.
Overview
Define units, scale, sign and rounding stage before coding the formula. Applying a rate once to a total may differ from rounding individual items before summation. Business rules determine the policy; Round alone does not implement tax or accounting rules. This memory-only exercise calculates a base and rounds to two places. Test zero, discounts, reversals and boundary values; record AppServer numeric settings during acceptance testing. (Sources: refs. 1–1.)
Commented example
#Include "Protheus.ch"
User Function Ed599()
Local nQuantity := 3
Local nPrice := 12.50
Local nRate := 0.10
// Round only at the stage defined by this exercise.
Local nTotal := Round(nQuantity * nPrice * (1 - nRate), 2)
ConOut(nTotal)
Return NilExpected numeric result: 33.75. Display depends on formatting. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.
- Do not confuse Round with NoRound; assess the entire environment before changing FloatingPointPrecise.
- Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.