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

tiger peng tigerpeng2001 at yahoo.com
Wed Jan 9 13:59:23 PST 2008

> tp> Here is my solution for fun:
>tp> perl -e '$t=13.32; $t =~ s/(\d+)(\.\d+)/$1.":". (int $2*60 +
 .5<10?"0":"").int $2*60 + .5/e; print "$t\n"'

>I think this is a little cleaner as a one-liner and will work with 
>$t = .32 for example:

> perl -e'$t = 13.32; printf "%d:%d\n", $t, ($t*60)%60;'
There is a small bug:
-> perl -e'$t = 13.02; printf "%d:%d\n", $t, ($t*60)%60;'


Chicago-talk mailing list
Chicago-talk at pm.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/chicago-talk/attachments/20080109/4a453da4/attachment.html 

More information about the Chicago-talk mailing list