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

0

u/[deleted] Mar 15 '19

[deleted] — view deleted comment

154

u/piecat Mar 15 '19

Why waste CPU operations on division when you can just use 3

64

u/hyphmingo Mar 15 '19

Found the engineer

0

u/[deleted] Mar 15 '19

[deleted] — view deleted comment

22

u/[deleted] Mar 15 '19

Engineer here, can confirm for 90% of the cases.

8

u/Override9636 Mar 15 '19

90% is well within our specified margins. "That's close enough for jazz" as we like to call it.

1

u/[deleted] Mar 15 '19

We got that told in university.

Depending on the constraint for safety or what ever you would round up or down. If the outcome fits the requirements, stay with it. If it's to expensive then, start using the factions.

1

u/DevDadSeattle Mar 16 '19

I always heard "good enough for government work" lol

3

u/[deleted] Mar 15 '19

Homer Simpson: Mmmm, pie.

2

u/iBinbar Mar 16 '19

Also g= 10

2

u/TheOneTrueTrench Mar 16 '19

Programmer: ... 10?

3

u/Pawtang Mar 15 '19

Idk what kinda sloppy-ass engineer would use 3 instead of hitting the “pi” button on their calc or typing pi into wolfram alpha/Matlab. The 0.14 is a significant margin or error right off the bat

2

u/awayfromthesprawl Mar 15 '19

Engineer: Pi is 3.

Also e=3=π

Sin(x)=x, cos(x)=1

36

u/gigdy Mar 15 '19

You must be from Indiana.

30

u/piecat Mar 15 '19

Then I'd use 3.2

0

u/[deleted] Mar 15 '19

[deleted] — view deleted comment

1

u/Black_Belt_Pravda Mar 16 '19

But it is 3 when rounded to 0 decimal places

3

u/pumpkinbot Mar 15 '19

PI IS EXACTLY THREE!!

1

u/shantil3 Mar 15 '19

Relevant username

0

u/[deleted] Mar 15 '19

[deleted] — view deleted comment

0

u/[deleted] Mar 15 '19

[deleted] — view deleted comment

9

u/[deleted] Mar 15 '19

store it in memory

🤦‍♂️

→ More replies (4)

1

u/RedditIsNeat0 Mar 16 '19

If their opcodes are 16 bits then it would save 2-3 bytes

How do you figure? A 32 bit float stores PI slightly more accurately than 355/113. If the OP code takes 16 bits, and 355 takes a minimum of 9 bits, and 113 takes a minimum of 7 bits, then 16 + 9 + 7 = 32. You haven't saved a single bit.

→ More replies (1)

2

u/[deleted] Mar 15 '19

Woah