[Chicago-talk] isolating the values to right and left of the decimal
Steven Lembark
lembark at wrkhors.com
Sat Jan 5 14:02:05 PST 2008
Richard Reina wrote:
> After over an hour of googling and searching in my Lama, Camel and Ram
> books I still am unable to find a way to convert
>
> 13.32 to: thirteen hours and nineteen minutes
>
> my $time_sring = 13.32;
>
> my $hrs = sprintf "%0d", $time_string; # works. I get 13
>
> but I can't figure out how to get .32 so that I can multiply it time 60
> and then round it so that I can print out:
>
> thirteen hours and nineteen minutes
my $time = 13.32;
my $hours = int $decimal_time;
my $min = ( $decimal_time - $hours ) * 60;
my $timestr = sprintf '%02d:%02d', $hrs, $min;
--
Steven Lembark 85-09 90th St.
Workhorse Computing Woodhaven, NY, 11421
lembark at wrkhors.com +1 888 359 3508
More information about the Chicago-talk
mailing list