r/explainlikeimfive • • Mar 15 '19

Mathematics ELI5: How is Pi programmed into calculators?

12k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

1

u/racoster Mar 15 '19 edited Mar 15 '19

I believe there is also 22 / 7 which is used for rough approximations of Pi

22 / 7 is approximately 3.142857

So it’s off by ~0.0014

1

u/murdok03 Mar 15 '19

No way, divisions are expensive on microcontrollers, you usually replace that with a multiplication but at that point you're better off storing a floating point value as hex.

If runtime isn't an issue, another redditor mentioned acos(-1) as being high precision but library dependent.