Caplin Trader 5.1.0

Class: module:br-formatting/SignificantFiguresFormatter

module:br-formatting/SignificantFiguresFormatter()

Formats a number to the specified number of significant figures.

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

SignificantFiguresFormatter.format(3.14159, {sf:4})

Constructor

new module:br-formatting/SignificantFiguresFormatter()

Implements:

Methods

format(vValue, mAttributes)

Formats a number to the specified number of significant figures.

Attribute Options:

Option Description
sf the number of significant figures to apply (does nothing if omitted).
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.