develooper Front page | perl.perl5.porters | Postings from December 2003

Re: Smoke 21893 irix64 6.5 6.5.20m IP27 r10000 (2 processors) /usr/share/src/cpan-current-dogberry

From:
Tels
Date:
December 19, 2003 11:52
Subject:
Re: Smoke 21893 irix64 6.5 6.5.20m IP27 r10000 (2 processors) /usr/share/src/cpan-current-dogberry
Message ID:
200312192152.46679@bloodgate.com
#!/usr/bin/perl -w

use strict;

print "perl v$] under $^O\n";

use POSIX;

foreach my $root (qw/80 81 99 100/)
  {
  foreach my $n (qw/2 3/)
    {
    my $x = $root ** $n;
    print "$root ** $n == $x:\n ";
    print "int: ", 
      int( $x ** (1 / $n) ),"\t";
    print "Posix::floor: ",
      POSIX::floor($x ** (1 / $n)),"\t";
    print "sprintf: ",
      int ( sprintf ("%.8f", $x ** (1 / $n) ) ),"\t";
    my $r = $x ** (1 / $n);
    $r = floor($r+.5) if abs($r/floor($r+.5)) < 1e-14;
    print "nearest: ", $r, "\n";

    }
  }




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About