How can pi be calculated to a set number of digits in PHP?

前端 未结 4 686
逝去的感伤
逝去的感伤 2021-01-05 11:18

How can I calculate the value of pi in PHP up to X decimal numbers.

4 decimal points

3.141

64 d

4条回答
  •  孤独总比滥情好
    2021-01-05 11:59

    PHP cannot hold a number that long as far as I know, but 22/7 is an ancient way to calculate PI, though that will not be any better than the PI constant included in PHP. Perhaps you are trying to output a long string of PI as an exercise.

提交回复
热议问题