Caplin Trader 5.1.0

Class: module:ct-element/formatter/RoundingFormatter

module:ct-element/formatter/RoundingFormatter()

new module:ct-element/formatter/RoundingFormatter()

Formats the value to the specified rounding.

RoundingFormatter is typically used in the XML Renderer Framework, but can be invoked programmatically as in the following example which evaluates to '3.142':

RoundingFormatter.format(3.14159, {dp:3})
Implements:

Methods

format(vValue, mAttributes) → {String}

Formats the number to the specified precision.

Parameters:
Name Type Description
vValue Variant

the number.

mAttributes Map

the map of attributes.

Properties
Name Type Description
sf int

the number of significant figures to apply.

dp int

the number of decimal places to apply.

rounding int

the number of decimal places to be rounded, omitting any trailing zeros.

Implements:
Returns:

the number, formatted to the specified precision.

Type
String