使用BigDecimal打印Pi [英] Using BigDecimal to print Pi
本文介绍了使用BigDecimal打印Pi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正试图使用BigDecimal来打印Pi,但事实证明这是不正确的
I'm tring to use BigDecimal to print Pi, but it turns out it's not accurate
BigDecimal d = new BigDecimal(Math.PI);
System.out.println(d);
以上答案给我"3.141592653589793115997963468544185161590576171875" 但是"3.141592653589793"之后的数字不正确
The above answer gives me "3.141592653589793115997963468544185161590576171875" but the digits after "3.141592653589793" is incorrect
这是怎么回事?我可以使用bigdecimal打印PI吗?
how this is happenning ? and can i use bigdecimal to print PI ?
推荐答案
查看全文