numberUtils
Reference
Utility functions for numeric formatting.
const { protrakUtils } = React.useContext(customWidgetContext);
const { round } = protrakUtils;
round(number, decimalPlaces?)
Rounds a number to the specified number of decimal places using a precision-safe algorithm (avoids floating-point rounding errors).
Parameters:
| Param | Type | Default | Description |
|---|---|---|---|
number | number | required | The number to round |
decimalPlaces | number | 2 | Number of decimal places |
Returns: number
round(3.14159); // → 3.14
round(3.14159, 3); // → 3.142
round(2.005, 2); // → 2.01 (precision-safe, not 2.00)
round(100); // → 100
round(-1.555, 2); // → -1.56