[Chicago-talk] isolating the values to right and left of the decimal

Richard Reina richard at rushlogistics.com
Sat Jan 5 14:35:28 PST 2008

Steve, thank you very much. I did not know about the int operator.  Works like a charm.  Thank you very much.

Have a great night!

Steven Lembark <lembark at wrkhors.com> wrote: 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
Chicago-talk mailing list
Chicago-talk at pm.org

Your beliefs become your thoughts.  Your thoughts become your words.  Your words become your actions.  Your actions become your habits.  Your habits become your values.  Your values become your destiny.  -- Mahatma Gandhi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20080105/a0e72c75/attachment.html 

More information about the Chicago-talk mailing list