Caplin Trader 5.1.0

Class: module:ct-element/formatter/TruncateDecimalFormatter

module:ct-element/formatter/TruncateDecimalFormatter()

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

Truncates the value to the specified number of decimal places.

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

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

Methods

format(vValue, mAttributes) → {String}

Truncates the value to the specified number of decimal places. If the value has already fewer decimal places than the supplied attribute, then the value is not changed.

Parameters:
Name Type Description
vValue Variant

the number (String or Number type).

mAttributes Map

the map of attributes.

Properties
Name Type Description
dp Number

the number of decimal places at which to truncate.

Implements:
Returns:

the number formatted to the specified precision.

Type
String