Official Content

Truncates the value of a given numeric expression.

Syntax

Trunc(numeric-expression, nK)

Where:
numeric-expression
    Must be a numeric expression containing constants, attributes, GeneXus functions or variables.

nK
    Must be a non-negative numeric constant or variable.

Type Returned:
Numeric

Scope

Objects: Procedure, Transaction, Web PanelWork Panel
Generators: .NET, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3),RPG, Cobol

Description

Truncates the value of numeric-expression  to nK decimals.

Samples

Trunc(1.5, 0) = 1
Trunc(1.4, 0) = 1
Trunc(1.25, 1) = 1.2
Trunc(1.24, 1) = 1.2

&var = 0 
&sum = 146
&count = 10
&avg = Trunc(&sum / &count , &var) // Result: &avg = 14

See Also

Round function
Truncate method










Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant