getPrecision incorrectly calculates precision of decimal with scientific notation
Reproduction: -Navigate to http://react-component.github.io/input-number/examples?path=/story/rc-input-number--decimal -Select decimal -Enter '0.000000xx' -Click out of the input
Expected - Value is preserved as entered Actual - Value is truncated
This is due to a difference in the calculation of precision by the getPrecision function between a decimal using scientific notation and not, for example, getPrecision(0.0000001234) would return 10 but getPrecision(1.234e-7) would return 7, surely they should both return 10.
I figured this would be a simple fix, so I tested a simple change (see below) but a lot of tests broke with my change, although the failing test I added to cover the issue did pass.
if (valueString.indexOf('e-') >= 0) {
if(valueString.indexOf('.') >= 0) {
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10) +
parseInt(valueString.slice(valueString.indexOf('.') + 1, valueString.indexOf('e-')).length);
}
return parseInt(valueString.slice(valueString.indexOf('e-') + 2), 10);
}