Caplin Trader 4.7.1

Class: module:caplin/element/formatter/RoundingFormatter

module:caplin/element/formatter/RoundingFormatter

Constructor

new module:caplin/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':

caplin.element.formatter.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.
Returns:
the number, formatted to the specified precision.
Type
String