We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f237f28 commit 9ad245eCopy full SHA for 9ad245e
1 file changed
components/lib/inputnumber/InputNumber.js
@@ -213,9 +213,13 @@ export const InputNumber = React.memo(
213
return null;
214
};
215
216
- const addWithPrecision = (base, increment, precision = 10) => {
217
- return Math.round((base + increment) * precision) / precision;
218
- };
+ const addWithPrecision = (base, increment) => {
+ const baseDec = (base.toString().split(".")[1] || "").length;
+ const incDec = (increment.toString().split(".")[1] || "").length;
219
+ const precision = Math.pow(10, Math.max(baseDec, incDec));
220
+
221
+ return Math.round((base + increment) * precision) / precision;
222
+ };
223
224
const repeat = (event, interval, dir) => {
225
let i = interval || 500;
0 commit comments