Did not apply change to one of the shifts.

pull/12/head
Favian Contreras 10 years ago
parent 35052bdac5
commit fad2446f27

@ -397,18 +397,20 @@
var Decimal = this['constructor'], var Decimal = this['constructor'],
x = this['trunc'](); x = this['trunc']();
var twoPowN = null; var twoPowN, nNum;
if (typeof n === 'object' || !isFinite(n) || +n >= 50) { if (typeof n === 'object' || !isFinite(n) || +n >= 50) {
n = new Decimal(n)['trunc'](); n = new Decimal(n)['trunc']();
if (POWERS_OF_TWO[n['toNumber']()] !== undefined) { nNum = n['toNumber']();
twoPowN = POWERS_OF_TWO[n['toNumber']()]; if (POWERS_OF_TWO[nNum] !== undefined) {
twoPowN = POWERS_OF_TWO[nNum];
} }
} else { } else {
if (isNaN(parseInt(n))) { if (isNaN(parseInt(n))) {
return new Decimal(NaN); return new Decimal(NaN);
} }
twoPowN = new Decimal(mathpow(2, n | 0)); nNum = n | 0;
n = new Decimal(n | 0); twoPowN = new Decimal(mathpow(2, nNum));
n = new Decimal(nNum);
} }
// Are both infinity or is shift amount negative or amount is negative and shift is infinite? // Are both infinity or is shift amount negative or amount is negative and shift is infinite?
@ -426,7 +428,7 @@
if (!twoPowN) { if (!twoPowN) {
twoPowN = new Decimal(2)['pow'](n); twoPowN = new Decimal(2)['pow'](n);
POWERS_OF_TWO[n['toNumber']()] = twoPowN; POWERS_OF_TWO[nNum] = twoPowN;
} }
var outVal = x['times'](twoPowN); var outVal = x['times'](twoPowN);

Loading…
Cancel
Save