Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Mathc

MathC(cNum1,cOperacao,cNum2) -> cResult

Performs arithmetic on numbers represented as strings.

MathcAdvPL
01 · OVERVIEW

Overview

MathC takes two text numbers and an operator: +, -, *, / or e for exponentiation. Its return is also text; documentation mentions up to 18 digits of precision. This is not the Match pattern-comparison function. Converting the result with Val may lose properties of its text representation. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

MathC(cNum1,cOperacao,cNum2) -> cResult

Parameters

cNum1
CharacterRequired

First text number.

cOperacao
CharacterRequired

Arithmetic operator.

cNum2
CharacterRequired

Second text number.

Return value

String containing the operation result.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed523()
    Local cResult := MathC("12.5","+","2.5")
    // The result remains a character string.
    ConOut(cResult)
    ConOut(ValType(cResult))
Return Nil
Expected result

Text value corresponding to 15 and type C; verify exact formatting in the runtime. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate operators, numeric format and divisors before calling; do not promise universal financial precision.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. MathC. 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