问题描述:
java四舍五入 保留两位小数
x1=((double)(-b)+Math.sqrt((double)d))/(2*(double)a);
\x05\x05\x05 x2=((double)(-b)-Math.sqrt((double)d))/(2*(double)a);
\x05\x05\x05x1=Math.round(x1/0.01)*0.01;
\x05\x05\x05x2=Math.round(x2/0.01)*0.01;
a=21 b=89 c=35 为什么x1能输出-0.44 但是x2就会变成-3.80000000000003呢?
x1=((double)(-b)+Math.sqrt((double)d))/(2*(double)a);
\x05\x05\x05 x2=((double)(-b)-Math.sqrt((double)d))/(2*(double)a);
\x05\x05\x05x1=Math.round(x1/0.01)*0.01;
\x05\x05\x05x2=Math.round(x2/0.01)*0.01;
a=21 b=89 c=35 为什么x1能输出-0.44 但是x2就会变成-3.80000000000003呢?
问题解答:
我来补答展开全文阅读