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

Oops - Can't calculate our powers

Thread Next
From:
Tim Jenness
Date:
July 17, 2003 19:28
Subject:
Oops - Can't calculate our powers
Message ID:
Pine.LNX.4.44.0307171615510.19189-100000@lapaki

We have a bit of a problem with 5.8.1RC2. Sorry this isn't filed in the 
bug system but I don't really have time...

Running the PDL test suite with 5.8.1-RC2 threw up a strange test failure.
After a bit of detective work it came down to this:

  -3 ** 3 != -27
  -3 ** 3 == 27

The following test script works on 5.8.0 and older but 5.8.1-RC2 fails for 
all integers that are not powers of 2.

 ie -1 ** 3 == -1
    -2 ** 3 == -8
    -3 ** 3 == 27
    -4 ** 3 == -64
    -5 ** 3 == 125

I'm hoping I'm just in the twilight zone and about to embarrass myself in
front of the whole list...

#!perl
use Test::More tests => 128;

my @test = (1..128);

my $pow = 3; # Test cubes

for (@test) {
  my $pospow = $_** $pow;
  my $negpow = (-$_) ** $pow;
  is( $pospow, (-1*$negpow));

}

perl -V at end (basically RH7.3, 5.8.1 with threads and random hash)
Same error in POSIX::pow()

-- 
Tim Jenness
JAC software
http://www.jach.hawaii.edu/~timj


Summary of my perl5 (revision 5.0 version 8 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.4.18-27.7.x, archname=i686-linux-thread-multi
    uname='linux lapaki 2.4.18-27.7.x #1 fri mar 14 06:44:53 est 2003 i686 unknown '
    config_args='-des -Dprefix=/local/perl-5.8 -Dusethreads -DUSE_HASH_SEED'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef useithreads=define usemultiplicity=define
    useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
    use64bitint=undef use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DTHREADS_HAVE_PIDS -fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.3 2.96-113)', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT
  Locally applied patches:
  	RC2
  Built under linux
  Compiled at Jul 14 2003 13:21:11
  %ENV:
    PERL5_CPANPLUS_CONFIG="/home/timj/.cpanplus/config"
  @INC:
    /local/perl-5.8/lib/5.8.1/i686-linux-thread-multi
    /local/perl-5.8/lib/5.8.1
    /local/perl-5.8/lib/site_perl/5.8.1/i686-linux-thread-multi
    /local/perl-5.8/lib/site_perl/5.8.1
    /local/perl-5.8/lib/site_perl
    .


Thread Next


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