Usina BRAdvPL Guide
Sign in
← All topics
FUNCTIONUnder review

Sqrt

Sqrt(nValue) -> nRoot

Calculates a numeric expression’s square root.

SqrtAdvPL
01 · OVERVIEW

Overview

Documentation describes positive roots and zero for negative input. That zero cannot distinguish invalid input from the root of zero. Validate the domain before calling rather than expecting an exception for negatives. (Sources: refs. 1–1.)

02 · SYNTAX

Syntax

Sqrt(nValue) -> nRoot

Parameters

nValue
NumericRequired

Radicand.

Return value

Numeric; zero for negative input per TDN.

03 · PRACTICAL EXAMPLE

Commented example

#Include "Protheus.ch"

User Function Ed673()
    Local nValue := 81
    // Reject a negative domain before calculation.
    If nValue >= 0
        ConOut(Sqrt(nValue))
    EndIf
Return Nil
Expected result

Displays 9 for input 81. Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

BEST PRACTICES
  • Validate type/sign; test zero, negatives and large values.
  • Under review: editorial example neither compiled nor run in Protheus. Check includes, release, RDD and context before testing.

Related content

REFERENCES
  1. TOTVS. Sqrt. Sintaxe e observações. TDN. Accessed on 2026-10-28.
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