Javascript代碼:乘法與Java,JavaScript中,Oracle和Windows計算器
var unitPrice,shippintObj;
var temp2=parseFloat(unitPrice * shippingObj.value);
document.getElementById("pAmountId"+shippingId).value =temp2.toFixed(3) ;
輸出: -
563361462829470100000
Java代碼:
double b;
long a;
a=456322789;
b=1234567890120.145;
System.out.println(a*b);
DecimalFormat ft=new DecimalFormat("#############################.###");
String c=ft.format(a*b);
System.out.println(c);
輸出: -
5.633614628294701E20
563361462829470100000
甲骨文(SQL):
select
to_char(456322789*1234567890120.145,'999999999999999999999999999999999D999')
from dual;
輸出: -
563361462829470111484.4050
窗計算器:
a=456322789;
b=1234567890120.145;
結果: -
563361462829470111484.4050
最後我的問題是,當我正在用Java,Javascript,SQL和Windows計算器做一個計算,我的結果對於Java,Javascript 是一樣的,但它不同於SQL,Windows計算器的答案。我想在Java和Javascript中獲得Oracle的結果。
謝謝。這真的很有用。 – 2012-02-06 11:55:03
StackOverflow鼓勵在他們解決您的問題時接受答案,或者如果他們以其他方式幫助您,則提高他們的答案。 – 2012-02-06 12:01:33