Skip to content

Commit 4e90c50

Browse files
committed
Additional precision tweaks...
1 parent 6942255 commit 4e90c50

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

precision/index.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export function configurePrecision (engine, constructor, compatible = true) {
303303
if (Number.isInteger(data[i])) res += item
304304
else {
305305
res += item | 0
306-
overflow += (item - (item | 0)) * 1e6
306+
overflow += +('0.' + item.toString().split('.')[1]) * 1e6
307307
}
308308
}
309309
return res + (overflow / 1e6)
@@ -315,6 +315,12 @@ export function configurePrecision (engine, constructor, compatible = true) {
315315

316316
for (let i = 0; i < data.length; i++) {
317317
const item = +data[i]
318+
319+
if (item > 1e6 || result > 1e6) {
320+
result *= item
321+
continue
322+
}
323+
318324
result *= (item * SCALE_FACTOR) | 0
319325
result /= SCALE_FACTOR
320326
}
@@ -341,7 +347,7 @@ export function configurePrecision (engine, constructor, compatible = true) {
341347
if (Number.isInteger(data[i])) res -= item
342348
else {
343349
res -= item | 0
344-
overflow += (item - (item | 0)) * 1e6
350+
overflow += +('0.' + item.toString().split('.')[1]) * 1e6
345351
}
346352
}
347353
return res - (overflow / 1e6)

0 commit comments

Comments
 (0)