From 364644d70d27f81ffd7e420bef811a3970ca3fc7 Mon Sep 17 00:00:00 2001 From: joelsantosjunior Date: Wed, 15 Sep 2021 11:24:37 -0300 Subject: [PATCH] fix: stack overflow issue for precision > 2 --- src/input.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/input.service.ts b/src/input.service.ts index 38afb44..17445d7 100644 --- a/src/input.service.ts +++ b/src/input.service.ts @@ -121,8 +121,13 @@ export class InputService { // Ensure max is at least as large as min. max = (this.isNullOrUndefined(max) || this.isNullOrUndefined(min)) ? max : Math.max(max, min); + // Ensure precision number works well with more than 2 digits + // 23 / 100... 233 / 1000 and so on + const divideBy = Number('1'.padEnd(precision + 1, '0')); + // Restrict to the min and max values. - let newValue = integerValue + (decimalValue / 100); + let newValue = integerValue + (decimalValue / divideBy); + newValue = isNegative ? -newValue : newValue; if (!this.isNullOrUndefined(max) && newValue > max) { return this.applyMask(true, max + '');