hour to minute

public real HoursToMinutes(real totalHours)
{
real minute,totalMinutes;
int hour;
hour=any2int(trunc(TotalHours));
// BP Deviation documented
minute=frac(decround(TotalHours,2));
if(minute!=0.00 || minute!=0)
// BP Deviation documented
TotalMinutes=(hour60)+(minute100);
else
// BP Deviation documented
TotalMinutes=(hour*60);
return TotalMinutes;
}

That’s nice [:D] anything else you need?

please explain the above code

Regards,

Sreenu

Hi,

The method is straight forward. For a given hours, it returns number of minutes.

thanks for reply my dought is here below we are taking minute*100 why should take 100

TotalMinutes=(hour60)+(minute100);

Hi,

You should look at the previous lines of code. Specifically the following lines -

// BP Deviation documented
minute=frac(decround(TotalHours,2));
if(minute!=0.00 || minute!=0)

In the first line, two standard functions are used - decround and frac. Look up these functions in MSDN.

For example, if the value in minute variable is 0.01, then multiplying minute with 100 will give 1 which is correct.