首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >java中的Big.js在IE中不起作用

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

Stack Overflow用户
提问于 2013-06-25 14:29:38
回答 1查看 111关注 0票数 0

我正在使用Big.js来比较Jsp.its中的数值,在Mozilla中工作得很好,但是当我在IE中检查它时,它不能正常工作。我已经使用了下面的Big.js code.Please,回顾它,并指导我做同样的事情。

我已经从http://github.com/whatgoodisaroad/Big-js使用过这个Big.js

代码语言:javascript
复制
            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));
            }
EN

回答 1

Stack Overflow用户

发布于 2013-08-27 20:14:02

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17290560

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档