Usina BRAdvPL Guide
Sign in
← All topics
FOUNDATIONUnder review

Calculation procedures in AdvPL

Separates inputs, calculation rules and rounding.

Calculation procedures in AdvPLAdvPL
01 · OVERVIEW

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.)

03 · PRACTICAL EXAMPLE

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 Nil
Expected result

Expected 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.

BEST PRACTICES
  • 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.

Related content

REFERENCES
  1. TOTVS. Round. TDN. Accessed on 2026-10-27.
Status
Under review
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha