I'm building a calculator app. When I press the %
button on the calculator, it multiplies the current value by 0.01.
If I do 52 * 0.01
, I'll get 0.52
. But if I press it again, it will calculate 0.52 * 0.01
, and I get 0.005200000000000001
.
This value gets displayed to the user of the app. How do I truncate the extra numbers to end up with 0.0052
so that it makes more sense?