Singleton
caplin.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":

caplin.element.formatter.TruncateDecimalFormatter.format(3.14159, {dp:3})

Constructor Summary

Attributes Name and Description
caplin.element.formatter.TruncateDecimalFormatter()

Method Summary

Attributes Name and Description
String format(Variant vValue, Map mAttributes)

Truncates the value to the specified number of decimal places.

Constructor Detail

caplin.element.formatter.TruncateDecimalFormatter()

Method Detail

String format(Variant vValue, Map mAttributes)

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.

Attribute Options:

Option Description
dp the number of decimal places at which to truncate.

Parameters
Variant vValue the number (String or Number type).
Map mAttributes the map of attributes.
Returns
the number formatted to the specified precision.