On 28/2/03 3:52 pm, Dave Rolsky at [EMAIL PROTECTED] spake thus:
> Finally, I think that Perl's built-in int() function does everything that
> floor() is being used for.  POSIX is a big memory hog, so getting rid of
> it is a good thing.

Don't be too sure Dave ... years before 0 and the difference is great.
Consider this:

use POSIX qw/floor/;
print "int  : " .   int(-243.23) . "\n";
# int  : -243
print "floor: " . floor(-243.23) . "\n";
# floor: -244
__END__

The module uses:
floor($y/4)
Where $y (year) could be a negative.

If POSIX isn't brought in, then at least a local floor should be
implemented:

sub floor($) {
    return 0 unless $_[0]*1 == $_[0]; # This might not be the best way :)
    return int($_[0]) if $_[0] >= 0;
    return int($_[0]) -1;
}

Cheers!
Rick


--------------------------------------------------------
             There are 10 kinds of people:
   those that understand binary, and those that don't.
--------------------------------------------------------
   The day Microsoft makes something that doesn't suck
     is the day they start selling vacuum cleaners
--------------------------------------------------------


Reply via email to