calc minutes to houre

time calc problem
i have this resuat of time :
10.60
its need to be 11 hours
the .60 is minutes
its need to be turn to 1 houre
i do this code ant its work good :

decimal time =(decimal)10.60;
decimal t = time % 2;
textBox2.Text = t.ToString();
decimal res =(t/60) * 100;
time = time - t;
decimal tot = time + res;
textBoxEx2.Text=tot.ToString();

now if the total hour is 10.70 insted of 10.60
i need to get 11 hours and 10 min = 11.10
i am geting wrong resualt 11:16

how can i fix that ?
thanks ...
Who is Participating?

Commented:
This will do what you want:
decimal time = (decimal)10.70;
int hours = (int)time;
time = time - hours;
int minutes = (Convert.ToInt32(time * 100));
int extraHours = minutes / 60;
minutes = minutes % 60;
int totalHours = hours + extraHours;
time = Convert.ToDecimal(totalHours) + Convert.ToDecimal(minutes ) /100;

Jim
0

Commented:
Generally what are you using this code for? what are you trying to do ?
0

Author Commented:
i mange but i still have a small problem
if the diff is a round number
i need to add the number .00

i need to check if the num is round and if he is round i need to attach the .00
if i get the num 8
i need to change it to 8.00
thanks..
0

Commented:
If you are looking to check if the number is round. you should look at Math.Round() function
0

Author Commented:
great
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.