mirror of
https://github.com/MikeMcl/decimal.js.git
synced 2024-10-27 20:34:12 +00:00
Remove duplicated for-loop. Minor refactoring.
This commit is contained in:
parent
148be72e6f
commit
27de48c4c3
10
decimal.js
10
decimal.js
@ -1909,9 +1909,6 @@
|
|||||||
if (carry) ++e;
|
if (carry) ++e;
|
||||||
else r.shift();
|
else r.shift();
|
||||||
|
|
||||||
// Remove trailing zeros.
|
|
||||||
for (i = r.length; !r[--i];) r.pop();
|
|
||||||
|
|
||||||
y.d = r;
|
y.d = r;
|
||||||
y.e = getBase10Exponent(r, e);
|
y.e = getBase10Exponent(r, e);
|
||||||
|
|
||||||
@ -3127,10 +3124,11 @@
|
|||||||
|
|
||||||
// Calculate the base 10 exponent from the base 1e7 exponent.
|
// Calculate the base 10 exponent from the base 1e7 exponent.
|
||||||
function getBase10Exponent(digits, e) {
|
function getBase10Exponent(digits, e) {
|
||||||
|
var w = digits[0];
|
||||||
|
|
||||||
// First get the number of digits of the first word of the digits array.
|
// Add the number of digits of the first word of the digits array.
|
||||||
for (var i = 1, w = digits[0]; w >= 10; w /= 10) i++;
|
for ( e *= LOG_BASE; w >= 10; w /= 10) e++;
|
||||||
return i + e * LOG_BASE - 1;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user