java中的Big.js在IE中不起作用
Big.js in java not working in IE
我使用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
相关文章:
- window.opener.document在ie中不起作用
- 为什么Telerik cdn在IE中不起作用
- JQuery脚本在IE中不起作用
- 默认光标在IE和Mozilla中不起作用
- Asp自定义验证器在IE-11中不起作用
- knockoutjsforeach在IE 9中不起作用
- 谷歌分析在IE中不起作用
- javascript中的SVG转换在IE 11中不起作用
- 用于播放背景音乐的嵌入式flash播放器在IE浏览器中不起作用
- 在IE中切换javascript不起作用的复选框
- JQuery日期选择器在IE 7上不起作用
- HTML表单在IE中不起作用
- Javascript style.background在IE中不起作用
- 对<asp:IE 10的TextBox;不起作用
- Javascript/AAJAX在Opera中不起作用,在FF/IE/Chrome中完美工作
- SPA异步调用在IE 11中不起作用
- 脚本在IE 9中不起作用
- ng-单击在IE中不起作用的选项选择Angularjs
- JQuery 双击侦听器在选择 - IE 不起作用
- 脸书登录IE不起作用