RoundingRule

You can use the RoundingRule function to round a parameter value according to a rule defined in the Rounding Rule form.

When to use

You can use this function to:

  • Round a parameter value according to a predefined business rule defined in the Rounding Rule form, rather than using generic mathematical rounding.
  • Ensure consistency across multiple formulas or items that share the same parameter, so all values are rounded using the same rule.

Syntax

double RoundingRule(double WholeValue, string ParamCode = "", string RuleCode = "", int AdditionalIncrements = 0)

Parameters

Parameter Type Required Description
WholeValue double Yes The numeric value to be rounded.
Note: Typically a minimum or maximum parameter value or calculated result.
ParamCode string Conditional* The parameter name or code to be rounded.
Note:  May be omitted in equations but mandatory in workflows
RuleCode string Yes The rounding rule code that references a rule defined in the Rounding Rule form.
Note:  Function throws exception if not provided
AdditionalIncrements int Optional The integer to add extra increments beyond the rules standard rounding logic.
Note:  default, the value is 0

Return Value

he application returns the rounded value as a double.

Prerequisites

  • The rounding rules must be defined in the Rounding Rule form.
  • The rule code cannot be null or empty.
Note: The function throws an exception if the rule code is not provided.

Examples

Example 1
Round Parameter Value Using Rounding Rule.
double CALCIUMVAL = (double)ObjProperty("VALUE.TPALL", "", "", "CALCIUM_SS", 2);
	long CALCIUMROUNDED = RoundingRule(CALCIUMVAL, "CALCIUM", "ROUNDING_RULE_CODE");
	MessageList("Calcium is rounded to = ", CALCIUMROUNDED);
Description
This example determines to round the parameter value of CALCIUM using the ROUNDING_RULE_CODE rule code.