What is the fastest way to get the value of π?

后端 未结 23 1794
自闭症患者
自闭症患者 2020-11-28 00:33

I\'m looking for the fastest way to obtain the value of π, as a personal challenge. More specifically, I\'m using ways that don\'t involve using #define constan

23条回答
  •  醉话见心
    2020-11-28 01:14

    With doubles:

    4.0 * (4.0 * Math.Atan(0.2) - Math.Atan(1.0 / 239.0))
    

    This will be accurate up to 14 decimal places, enough to fill a double (the inaccuracy is probably because the rest of the decimals in the arc tangents are truncated).

    Also Seth, it's 3.141592653589793238463, not 64.

提交回复
热议问题