in reply to Re: Best Material for Floors:
in thread Best Material for Floors:

Bleh. POSIX::floor() on a Perl that uses "long double" (or similar) as NVs induces a great reduction in precision. Much better to just use:

sub floor { $_[0] < 0 ? -int(-$_[0]) : int($_[0]); }
sub floor { my $i= int( my $f= shift @_ ); return $i - ( $f<0 && $f!=$ +i ); }

Now you know. :)

- tye        

Replies are listed 'Best First'.
Re^3: Best Material for Floors: (POSIX--)
by lidden (Curate) on Dec 01, 2007 at 11:04 UTC
    floor -2.5 Should return -3.

      Heh, thanks. Fixed. Since I discovered the problem working with really large numbers, even my previous version was tons more accurate than POSIX::floor in that particular situation so it fixed the problem. That's how bad POSIX::floor can be.

      - tye