0

Approximate Cube Root

I found this code somewhere, the answer is getting some error margins in it. The answer should be a multiple of 0.01 but it is not. 20100×0.01=201, not 200.99999..... https://code.sololearn.com/cRjIy6cA9k6I/?ref=app

12th Jun 2017, 3:35 PM
ramkrishan charan
ramkrishan charan - avatar
1 Réponse
+ 3
Decimals (floating point numbers) are often inaccurate. You could round if the number is roughly 0.000001 away from a whole number. That could fix the issue for most values.
12th Jun 2017, 3:50 PM
Rrestoring faith
Rrestoring faith - avatar