Topic: 看不懂的double

  Print this page

1.看不懂的double Copy to clipboard
Posted by: aiff
Posted on: 2004-09-18 17:30

public class yuan{
public static void main(String args[])
{
double s,r=10,pi=3.1415;
s=pi*r*r;
System.out.println("the s is "+s);

}
}

答案是

2.Re:看不懂的double [Re: aiff] Copy to clipboard
Posted by: 牛老板
Posted on: 2004-09-18 18:01

浮点是非精确的实数.

可以使用java.text.DecimalFormat得到你期望的有效数字.

3.Re:看不懂的double [Re: aiff] Copy to clipboard
Posted by: liuyongsu
Posted on: 2004-09-19 07:53

确实,浮点数总是要丢失精度的。


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923