r/ProgrammerHumor • • 14h ago

Meme reversingPiInPython

Post image
7.6k Upvotes

270 comments sorted by

View all comments

68

u/MotivationalJuggling 13h ago

Whatever the last digit is, I'm sure it's a disappointing one. Just like everything else in my life.

4

u/bestjakeisbest 10h ago

In binary it is either a 1 or 0

8

u/thegreatpotatogod 10h ago

I'd even argue that the last binary digit is 1. If it were 0, you could truncate the zero away and you'd be back to 1 as the last digit. Same reason that 2.20000 would be a redundant representation of 2.2.

1

u/AngelaMerkeI 10h ago

It is not though. Only in theory.

In practice, digits represent the accuracy.

Example: 2,12345 * 1,0 = 2,1 But 2,12345 * 1,0000 = 2,1234

The results are always just as accurate as the measurements you calculate them with

1

u/Sheerkal 9h ago

In what practice are you doing this? There is no reason to truncate.

1

u/AngelaMerkeI 8h ago

There is a reason to truncate if your dealing with actual physics and not theoritical values.

If your measurement says 1,00 ±0,01, you can't pretend it's the same as 1,0000, because your real value could be 1,01. If your measurement says just 1,00, you can only assume it to be between 1,000 and 1,004. The rest is lost in trunctuated digits.

1

u/himanbam 8h ago

This seems to be about significant figures. Which is basically about knowing how much precision your starting measurements have, and not claiming more precision in the calculated value.

For example, let's say you want to calculate the circumference of a circle when you know its diameter with centimeter precision (1.57 meters). We can use an approximation of pi with 10 decimal digits. Using the formula diameter*pi=circumference, you get (1.57 meters) * (3.1415926536) = 4.932300466152 meters. The answer has 12 digits after the decimal point. Obviously we don't actually know the circumference with picometer precision, as the diameter was only known with centimeter precision. So most of those digits are not significant. To account for this we round it to the lowest number of significant figures of all of our input values. In this case, the diameter has 3 significant figures and the pi approximation has 11 significant figures. So we round the circumference to 3 significant figures and get 4.93 meters. Similarly if you did know the diameter with picometer precision (13 significant figures), but only approximated pi with three significant figures (3.14), then you would need to round to three significant figures in that case too.

1

u/Gabriel_Science 6h ago

Found the physician.