java中的Big.js在IE中不起作用

Big.js in java not working in IE

本文关键字:IE 不起作用 js 中的 Big java      更新时间:2023-09-26

我使用Big.js来比较Jsp中的数值。它在Mozilla中运行良好,但当我在IE中检查它时,它运行不正常。我使用了下面的Big.js代码。请复习并指导我。

我使用了http://github.com/whatgoodisaroad/Big-js 中的Big.js

            Big.prototype.lessThanOrEqualTo = function(right) {
            var c = compare(this, right);
            return c == LT || c == EQ;
            };
            function compare(bl, br) {
            bl = bl.clone();
            br = br.clone();
            if (bl.sign != br.sign) {
            if (bl.sign == POSITIVE)                    { return GT; }
            else /* (bl.sign == NEGATIVE) */            { return LT; }
            }
            else if (bl.exponent != br.exponent) {
            if (bl.sign == POSITIVE) {
            if (bl.exponent > br.exponent)          { return GT; }
            else                                    { return LT; }
            }
            else {
            if (bl.exponent > br.exponent)          { return LT; }
            else                                    { return GT; }
            }
            }
            else {
            var same = sameExponent(bl, br);

            return bl.sign == POSITIVE ?
            compareMantissae(same.l.mantissa, same.r.mantissa) :
            compareMantissae(same.r.mantissa, same.l.mantissa);
            }
            }
            // Compare only mantissae, assuming they correspond to equal 
            // exponents:
            function compareMantissae(m1, m2) {
            m1 = m1.slice();
            m2 = m2.slice();

            if (!m2.length) {
            if (mantissaIsZero(m1)) { return EQ; }
            else                    { return GT; }
            }
            else if (!m1.length) {
            if (mantissaIsZero(m2)) { return EQ; }
            else                    { return LT; }
            }
            if (m1[0] > m2[0])          { return GT; }
            else if (m1[0] < m2[0])     { return LT; }
            return compareMantissae(m1.splice(1), m2.splice(1));
            }
In Big.js there are compareMantissae() function
function compareMantissae(m1, m2) {
m1 = m1.slice();
m2 = m2.slice();
if (!m2.length) {   
    if (mantissaIsZero(m1)) { return EQ; }
    else                    { return GT; }
}
else if (!m1.length) {
    if (mantissaIsZero(m2)) { return EQ; }
    else                    { return LT; }
}
if (m1[0] > m2[0])          { return GT; }
else if (m1[0] < m2[0])     { return LT; }
// return compareMantissae(m1.splice(1), m2.splice(1));
return compareMantissae(m1.splice(-1*(m1.length-1),(m1.length-1)),m2.splice(-1*(m2.length-1),(m2.length-1)));
}
in this function there are change instead of
// return compareMantissae(m1.splice(1), m2.splice(1));
put this
return compareMantissae(m1.splice(-1*(m1.length-1),(m1.length-1)),m2.splice(-1*(m2.length-1),(m2.length-1)));
its working in IE(6,7,8,9),Mozilla and Chrome also.
this function works like this,
array.splice(index,howmany,item1,.....,itemX);
Parameter
index : Required. An integer that specifies at what position to add/remove items, Use negative values
to specify the position from the end of the array
howmany : Required. The number of items to be removed. If set to 0, no items will be removed
item1, ..., itemX : Optional. The new item(s) to be added to the array