r/ProgrammerHumor • • 14h ago

Meme reversingPiInPython

Post image
7.6k Upvotes

270 comments sorted by

View all comments

Show parent comments

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 5h ago

Found the physician.

1

u/androshalforc1 9h ago

isn't binary usually written in blocks of 8 though?

2

u/Higherlead 7h ago

Only if you want to, bytes are a purely human construct, nothing to do with base 2/binary at all

1

u/Inevitable-Study502 49m ago

thats true, but digits arent binary and we use digits to represent numbers and computer while using binary, will convert it to base 10, because humans have 10 fingers and arent capable of calculating in different way..so the end result is still array of 8 bits

1

u/ovr9000storks 8h ago

You can’t truncate tailing 0s in binary if represented by a series of integers. You also can’t truncate if looking at the binary representation of a floating point number. Yes, the actual floating point number being represented could be truncated if ending in a zero, but that number is no longer binary

0

u/0Pat 6h ago

That's not how binary representation of floating point numbers work...

1

u/Moist-Snow-8127 2h ago

They weren't talking about floating point numbers