Truncate

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Math operations, strings and data validations > Perform Math operations >

Truncate

Overview

This function truncates a number to an integer by removing its decimal, or fractional part

 

CHelper.Math.Truncate(Number)

 

The parameter of this function can be defined as an XPath, variable or number.

 

Considerations

Input parameters must be double.

The supported attribute types to use as input XPath parameter (or Xpaths stored in variables) are: integer, currency, float, real.

The function returns an error if the input parameter is either too long or undefined.

Use the IsNaN function to validate the parameter is a number.

 

Example

In a Purchase Request Process an estimation of the price of a product is made based on the last three purchases of that product. The purchasing values are averaged to obtain the estimation. Likely this estimation will have a decimal part. In order to obtain an integer value, the Truncate function can be used:

 

Math20

 

//Obtain the estimated price by averaging the last three purchasing prices

EstimatedPrice = CHelper.Math.Average([<Product.Price1>,<Product.Price2>,<Product.Price3>]);

//Obtain the integer part of the estimated price

<Product.IntEstimatedPrice> = CHelper.Math.Truncate(EstimatedPrice);


Last Updated 1/6/2022 4:20:15 PM