The Devil in the Decimals
The problem is that, as much as math.sqrt(5)
looks an awful lot like , it isn't. It's the closest thing you can get to that using 64 bits of information, writing it as a binary value.1 Specifically, Python floats are represented as a binary decimal with 532 significant base-2 digits. That's roughly equivalent to 16 significant base-10 digits. is 50 bits, and so the computer simply runs out of room and ends up misrounding the output.
Well, the simple solution here is to find a way of using more decimal places. Let's check it out.
False
The Devil in the Decimals
The problem is that, as much as math.sqrt(5)
looks an awful lot like , it isn't. It's the closest thing you can get to that using 64 bits of information, writing it as a binary value.1 Specifically, Python floats are represented as a binary decimal with 532 significant base-2 digits. That's roughly equivalent to 16 significant base-10 digits. is 50 bits, and so the computer simply runs out of room and ends up misrounding the output.
Well, the simple solution here is to find a way of using more decimal places. Let's check it out.
False