silentmatt/javascript-biginteger — Issue #9: IE does not support array.splice(negative_value), patch included in issue description
Author: eprost
Created: 2011-12-28 00:24:10+00:00
State: open

In BigInteger.parse, after "// Optimize 10", the while loop uses digits.splice(-BigInteger.base_log10) which equates to digits.splice(-7).

This is not supported by IE (see ref #2 below) => on IE8 (in "IE8 mode"): infinite loop.

In order to overcome the problem, I have replaced this (around line 392):

var d = [];
while (digits.length >= BigInteger.base_log10) {
d.push(parseInt(digits.splice(-BigInteger.base_log10).join(''), 10));

by this:

var d = [];
while (digits.length >= BigInteger.base_log10) {
d.push(parseInt(digits.splice(digits.length-BigInteger.base_log10, BigInteger.base_log10).join(''), 10));

I have successfully run the test suite with this patched code + rhino 1.7R2-3 on Ubuntu 10.04 x86 (aka "lucid"):
> ./run-test
[...]
Finished in 12.175
Passed 29/29 (100.00%): PASS

References :
1 - splice() at MDN: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/splice
2 - splice() at MSDN: http://msdn.microsoft.com/en-us/library/wctc5k7s(v=VS.94).aspx