I have multiple numbers of minutes and hours. What I want to do, is add all them up together. For example: if I have the numbers: 31, 15 and 45. Those are for minutes. I then have 2, 3 and 1 which are for hours. I want to add all the numbers and get the hours and minutes.
I so far added all the minutes together (31 + 15 + 45 = 91), then I multiplied all the hours by 60 (2 * 60 = 120; 3 * 60 = 180; 1 * 60 = 60) so they get converted to minutes.
I then add the final numbers together (91 + 120 + 180 + 60 = 451).
The final step would be to divide 451 / 60 = 7.5166666...7.
My question is, being that what I did so far was correct, how do I get the final number to be rounded out to the hundredths place, so that 7.51666... will become 7.52?
I will be displaying the final number (7.52) in a UILabel
.
This question doesn't answer my question because that question is asking how to round off numbers to the nearest .5. My question, is how to round off a number.