Common Number Formatters
The following formatters are the most common number formatters. An example for each formatter is provided for reference.The square brackets around the optional parameters of some formatters are not required. They are there to denote that the parameter is optional.
add(value)
Adds the input attribute/value to the value parameter and returns the result. The default value is1.
Example
greaterthan(value[, ifgreater][, ifnotgreater])
Returns true if the input attribute/value is greater than the value parameter, and false otherwise. If ifgreater is supplied, that value is returned instead of true (if the input is greater than value), and if ifnotgreater is supplied, that value is returned instead of false (if the input is not greater than value).Example
lessthan(value[, ifless][, ifnotless])
Returns true if the input attribute/value is less than the value parameter, and false otherwise. If ifless is supplied, that value is returned instead of true (if the input is less than value), and if ifnotless is supplied, that value is returned instead of false (if the input is not less than value).Example
multiply(value)
Multiplies the input attribute/value with the value parameter and returns the result.Example
rand(upperBound)
Generates a random integer between 0 and upperBound. This formatter does not modify the input attribute (variable), so no input attribute is required.Example
Other Number Formatters
The following formatters are less common than those described in the previous section.abs()
Returns the absolute value of the numeric attribute value.and(value)
Returns the AND of two values. The values provided on each side must be 1/0, yes/no, or true/false.- value: The boolean value to compare by.
ceiling()
Returns the smallest integer greater than or equal to a numeric attribute value.currency([integer_count])
Returns the numeric value formatted as currency.- count: An optional number specifying how many places to the right of the decimal to display. The default is
2.
decimal([integer_count])
Returns the numeric value formatted as a decimal number, with commas to delimit thousands, millions, and so on.- count: An optional number specifying how many places to the right of the decimal to display. The default is
2.
div([value])
Returns the result of dividing the numeric attribute value by the specified value of the parameter.- value: An optional numeric value to divide the numeric attribute value by. The default is
2.
divide([value])
Returns the result of dividing the numeric attribute value by the specified value of the parameter.- value: An optional numeric value to divide the numeric attribute value by. The default is
2.
expr(expression)
Evaluates the mathematical expression.- expression: The expression.
floor()
Returns the largest integer less than or equal to the numeric attribute value.format(pattern)
Formats a numerical result based on the provided pattern and the platform’s behavior.- pattern: The formatting pattern to use.
Examples
tmp attribute, set to $1,440.123, is passed through the format("#.##") formatter. The result is $1440.12.
rnd attribute, set to 1055.68, is passed through the format("#.#") formatter. The result is 1055.7.
isbetween(integer_lowvalue, integer_highvalue[, ifbetween][, ifnotbetween])
Returns true (or ifbetween) if the attribute value is greater than or equal to the first parameter value, and less than or equal to the second parameter value. Otherwise it returns false (or ifnotbetween).- lowvalue: The lower bound of the range to check.
- highvalue: The higher bound of the range to check.
- ifbetween: The optional value returned if the attribute value is greater than or equal to the first parameter value and less than or equal to the second parameter value.
- ifnotbetween: The optional value returned if the attribute value is less than the first parameter value or greater than the second parameter value.
isequal(value[, ifequal][, ifnotequal])
Returns true (or ifequal) if the attribute value is equal to the parameter value. Otherwise it returns false (or ifnotequal).- value: The numeric value to compare with the attribute value.
- ifequal: The optional value returned if the attribute value is equal to the parameter value.
- ifnotequal: The optional value returned if the attribute value is not equal to the parameter value.
modulus(value)
Returns the modulus of the numeric attribute value divided by the specified parameter value.- value: The number to divide the attribute value by.
number(value[, format][, locale])
Returns the numeric value formatted as a decimal number. Provides the option to add formatting and locales.-
format: An optional decimal number format. The default is
#.00. You can use the following special characters:Character Description 0Digit #Digit; zero shows as absent .Decimal separator or monetary decimal separator -Minus sign ,Group separator -
locale: The locale information. The default is invariant culture or locale, which means that it’s not associated with a particular country or region. It accepts language tags (for example,
en,fr,en-US,en-IN,fr-FR, andzh-CN).
or(value)
Returns the OR of two values. The values provided on each side must be 1/0, yes/no, or true/false.- value: The boolean value to compare by.
percentage([integer_count])
Returns the numeric value formatted as a percentage.- count: An optional number that indicates how many places to the right of the decimal to display.
pow([value])
Returns the numeric attribute value raised to the power specified by the parameter value.- value: An optional power to raise the attribute value to. The default is
2.
round([integer_value])
Returns the numeric attribute value rounded to the number of decimal places specified by the parameter.- value: An optional number of decimal places. The default is
2. - rounding_mode: Specifies the rounding behavior for numerical operations capable of discarding precision. Accepted values are:
Default,ToEven,AwayFromZero,ToZero,ToNegativeInfinity,ToPositiveInfinity. The default rounding strategy used is based on your operating system. .NET uses ToEven, and Java uses Half Even.
RoundingMode environment variable and provide one of the rounding_mode values as its value. When you do this, uses that rounding mode any time a rounding_mode has not been explicitly specified in the formatter. To be more specific, checks for values in this order:
rounding_modeinput- The
RoundingModeenvironment variable - The default as determined by the operating system, as described above
sqrt()
Returns the square root of the numeric attribute value.subtract([value])
Returns the difference between the numeric attribute value and the value specified by the parameter.- value: The optional numeric value to subtract the attribute value by. The default value is
1.