I'm trying to convert minutes to hours in decimal and round to the nearest fifteen minutes (rounded up).
Basically:
15 minutes = 0.25 hour
25 minutes = 0.5 hour
30 minutes = 0.5 hour
50 minutes = 1 hour
60 minutes = 1 hour
I haven't found anything relevant here on stackoverflow but another website tells me to:
var hours = Math.Round((minutes * 100 ) / 60.0);
Which doesn't come near to the result.
I know I can't use Math.Round()
(because it casts it to an int?). Same for TimeSpan
(because it gives .TotalHours
in a double
).
What can a good approach be starting with dividing it by 60?