i currently have an integer int i
and its value is 60
i wish to divide this by 100
to get 0.60 but i cannot do this please help
int i = 60;
int x = 60 / 100; // Dosen't work should be 0.60 instead returns 0
There cannot be decimals in the divisor; therefore, remove the decimal point from the divisor and add as many zeros to the dividend as there are digits after the decimal point. In this case, we have to add only one zero.
divide by 100.0f and return result into a float.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With