javascript - More accurate value of Pi?

前端 未结 2 1578
春和景丽
春和景丽 2020-12-20 19:40

I type Math.PI; in Chrome Console and this is returned:

3.141592653589793

Then I type Math.PI - 3.14159265358

2条回答
  •  隐瞒了意图╮
    2020-12-20 20:22

    I don't see why you would need PI to such accuracy but you can either :

    a) Calculate PI yourself using Leibniz formula

    b) Define PI yourself (using this library)

    var PI = new bigdecimal.BigDecimal("3.141592653589793238462643383279");
    


    You can find first 100,000 digits of PI here if you really need it.

提交回复
热议问题