On Fri, Apr 26, 2002 at 09:51:11PM +0200, Mail WebOn AS wrote:
> Was looking through the PGAS code and ran into these lines :
> 
> # Is there a better way to do this? Probably
> my $day  = int($time_left/(60*60*24));
> my $hour = int(($time_left%(60*60*24))/(60*60));
> my $min  = int((($time_left%(60*60*24))%(60*60))/60);
> my $sec  = int((($time_left%(60*60*24))%(60*60))%60);

I'd observe that the repeated moduluses are redundant.  $time_left %
(60*60*24) % (60*60) is equivalent to $time_left % (60*60), because 60*60
is a factor of 60*60*24.  int() is also redundant; modulus returns an
integer by definition.

my $day  = int($time_left/(60*60*24));
my $hour = $time_left % (60*60*24);
my $min  = $time_left % (60*60);
my $sec  = $time_left % 60;

Ronald

Reply via email to