计算圆的周长

  • 1
  • 已锁定
我们有一个计划。现在来实现它。首先,实现一种计算圆周长的方法。要完成此任务,你需要在方法中写入正确的公式并指定参数。但是 pi 呢?我们知道它是 3.141592... 直至无穷。我们把问题简化一下:让 pi = 3.14。
无法完成此任务,因为你尚未登录。
评论 (9)
  • 受欢迎
你必须先登录才能发表评论
1960365339
级别 3 ,Jinan,China
11 三月, 02:45
我是有漏掉的课吗,怎么到这看不懂了呢
wen
级别 6 ,China,China
14 十二月 2022, 03:20
public static void main(String[] args) throws Exception { printCircleCircumference(2); 第二句"printCircleCircumference(2);"是什么意思
Sohyla Sherief
级别 2 ,Istanbul
3 十二月 2021, 08:52
why my first requirement always has a problem?
null
级别 3 ,Fuzhou
18 三月 2021, 10:12
System.out.printf("______%2f",circle); just like C
maungnge
级别 8 ,Rangoon,Myanmar
2 十月 2020, 15:49
because double!
graven
级别 3 ,Singapore,Singapore
8 八月 2020, 13:37
why my output is "31.400000000000002" but not "31.4" ? very interesting i am sure i used pi = 3.14
tizo chan
级别 12
21 十二月 2020, 07:18
my question is same like youuu,so why??????
Kevin_WWW
级别 11 ,China
19 二月 2021, 15:43
Computers cannot represent floating-point numbers accurately. You can use this code: double r = 5; double pi = 3.14; DecimalFormat df = new DecimalFormat("0.0"); System.out.println(df.format(2*r*pi)); It will print 31.4 instead of 31.400000000000002
222
级别 6
17 四月 2021, 01:49
Your computer does not save floating point numbers directly, but takes the floating point number *2 and subtracts 1 before bringing the result into a new round of calculations, and pi with this calculation results in an infinite number of bits, while the double type has a limit on the number of decimal places saved, so the result is 31.400000000000002 (this is a machine flip)