Caplin Trader 5.0.0

Class: module:br-formatting/DecimalFormatter

module:br-formatting/DecimalFormatter()

Formats the value to the specified number of decimal places.

DecimalFormatter is typically used with Presenter, but can be invoked programmatically as in the following example which evaluates to "3.142":

If you are using this formatter in conjunction with the ThousandsFormatter in a localised application, please ensure this DecimalFormatter is applied before the ThousandsFomatter, otherwise localised decimal point characters will stop the DecimalFormatter from recognising the number.

DecimalFormatter.format(3.14159, {dp:3})

Constructor

new module:br-formatting/DecimalFormatter()

Implements:

Methods

format(vValue, mAttributes)

Formats the value to the specified number of decimal places.

Attribute Options:

Option Description
dp the number of decimal places to apply.
Parameters:
Name Type Description
vValue Variant

the number (String or Number type).

mAttributes Map

the map of attributes.

Implements:
Returns:

the number, formatted to the specified precision.