I have a number (say 34) and I want to find its next multiple of ten. I can do it:
- Dividing the number by 10
- Rounding to integer
- Multiplication by 10.
After a little research, I found that this is the code for Objective-C:
int number = 34; int roundedNumber = ceil((double)number/10)*10;
My question is: what is (double) for, and why does deleting (double) make it round, not up?
I understand that from googling it changes the float format to "double precision", but to be honest, it's too complicated for me. Can someone give a simple explanation of what he is doing?
source share