+ 1
Noob Cube Root Program
So made this program for the cube root challenge and it calculates the cube root till the precision of 0.0001(as required in the challenge). There is one problem though. It gives some nonsense decimal digits after giving the answer. I don't understand why my loop isn't breaking after the answer has achieved the required precision. I just started coding yesterday so I am a super noob, please keep that in mind while answering. https://code.sololearn.com/cGw5PaRDRHfo/?ref=app
2 Respostas
+ 2
Those "nonsense" digits appear because decimals can't be represented exactly in binary.
print(0.1+0.2==0.3)
# False
# But it's clearly True
print(0.1+0.2)
# 0.30000000000000004
https://stackoverflow.com/questions/1089018/#1089026
+ 2
Thanks Diego. Atleast I know that my logics were not wrong lol.