[]
The format property defines the numeric precision applied to values in the InputNumber control.
When a value contains more decimal places than allowed by the format, the control applies a precision rule.
By default, InputNumber rounds values that exceed the defined precision.
Set the truncate property to control whether excess decimal digits are rounded or truncated.
When truncate is false (default), values that exceed the precision defined by format are rounded.
For example:
import * as input from '@mescius/wijmo.input';
const inp = new input.InputNumber('#el', {
format: 'n2'
});
inp.value = 99.999;
console.log(inp.value); // 100In this case, the value is rounded to two decimal places as defined by 'n2'.
Set the truncate property to true to discard extra decimal places instead of rounding.
const inp = new input.InputNumber('#el', {
format: 'n2',
truncate: true
});
inp.value = 99.999;
console.log(inp.value); // 99.99When truncate is true, decimal digits beyond the precision defined by format are removed without rounding.
This rule applies when:
Users enter values directly.
Values are pasted into the control.
Values are assigned programmatically.
The format property changes and triggers reformatting.
During direct editing, once the number of decimal places matches the precision defined by
format, additional digits cannot be appended at the end of the value. Users can still modify the number by moving the cursor and entering digits at another position.