Using Perl 5.8.3, this command generates correct output:
$ /usr/local/perl-5.8.3/bin/perl -le 'print +(-2)**4;'
16
But this command does not:
$ /usr/local/perl-5.8.3/bin/perl -le 'use bignum; print +(-2)**4;'
-16
I suggest something is definitely wrong with bignums somewhere :-).
Output of "perlbug -d" is appended.
- Pat
---
Flags:
category=
severity=
---
Site configuration information for perl v5.8.3:
Configured by patl at Mon Feb 9 19:36:03 EST 2004.
Summary of my perl5 (revision 5.0 version 8 subversion 3) configuration:
Platform:
osname=linux, osvers=2.4.20-20.9, archname=i686-linux
uname='linux mumm-ra.curl.com 2.4.20-20.9 #1 mon aug 18 11:45:58 edt 2003 i686 i686 i386 gnulinux '
config_args='-d'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
optimize='-O3',
cppflags='-fno-strict-aliasing -I/usr/local/include -I/usr/include/gdbm'
ccversion='', gccversion='3.2.2 20030222 (Red Hat Linux 3.2.2-5)', 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 -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.2'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.3:
/usr/local/perl-5.8.3/lib/5.8.3/i686-linux
/usr/local/perl-5.8.3/lib/5.8.3
/usr/local/perl-5.8.3/lib/site_perl/5.8.3/i686-linux
/usr/local/perl-5.8.3/lib/site_perl/5.8.3
/usr/local/perl-5.8.3/lib/site_perl
.
---
Environment for perl v5.8.3:
HOME=/u/patl
LANG=POSIX
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/curl/bin:/u/patl/bin:/usr/local/sbin:/sbin:/usr/sbin:/u/patl/bin:/usr/local/sbin:/sbin:/usr/sbin
PERL_BADLANG (unset)
SHELL=/bin/bash
Looks like a constant folding issue.
$ perl -MO=Deparse -le 'use bignum; print +(-2)**4;'
BEGIN { $/ = "\n"; $\ = "\n"; }
use bignum;
print {sign => '-', value => [16]};
-e syntax OK
--
Michael G Schwern sch...@pobox.com http://www.pobox.com/~schwern/
Perl_croak(aTHX_ "Believe me, you don't want to use \"-u\" on a Macintosh");
-- toke.c
Moin,
"Patrick J. LoPresti" wrote:
>Using Perl 5.8.3, this command generates correct output:
>
> $ /usr/local/perl-5.8.3/bin/perl -le 'print +(-2)**4;'
> 16
>
>But this command does not:
>
> $ /usr/local/perl-5.8.3/bin/perl -le 'use bignum; print +(-2)**4;'
> -16
>
>I suggest something is definitely wrong with bignums somewhere :-).
Thank you for the report. This bug is quite old, and was reported to me on
2004-01-22 by Stephen Ross. A fix for it is in the upcoming v1.70.
# perl -le 'use bignum; print +(-2)**4;'
-16
# perl -le 'use bigint; print +(-2)**4;'
-16
# perl -Ilib -le 'use bigint; print +(-2)**4;'
16
Math::BigInt v1.70 is already done, but because I changes quite some thing I
wanted to finish Math::BigInt::GMP and do some stresstests before relwasing
it. MBI::GMP is also done except one routine, _int_log() which needs
converting from C to XS (or at least from Calc to GMP). My plans were to
release v1.70 this weekend. You can have a sneak-preview at
http://bloodgate.com/perl/packages/devel/
If there is interest, I can also provide a patch for v1.69 that fixes just
this bug in bpow().
Best wishes,
Tels
- --
Signed on Wed Feb 11 18:43:09 2004 with key 0x93B84C15.
Visit my photo gallery at http://bloodgate.com/photos/
PGP key on http://bloodgate.com/tels.asc or per email.
"Nuclear powered vacuum cleaners will probably be ready within 10 years."
Alex Lewyt, of the Lewyt Corporation, a vacuum maker, predicted in The New
York Times on June 10, 1955 -- A warning to all technophiles
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)
Comment: When cryptography is outlawed, bayl bhgynjf jvyy unir cevinpl.
iQEVAwUBQCpq2HcLPEOTuEwVAQFmuwf/SZna5XqZTaz6P75gtv3GRB3NWfI6T3mm
qkKnWrNOR+o3BS1Wa7Mtt8P+Wwmohs/hMVvfzZSvuBTyvyvnxQcW8WS2VZUp5xhb
BI6e98Tl7LDlE3lvljN3VpVn6dmM6BWjEegcRgmMjXLlOfnYViu7krZRHKt8+GSd
mhYnYoUYi0MNCmAzSDCBhla/0NzsMsHZxZBrvT8pipPZd6K47KgP/HNMLxsqxnOB
sTeZd0wHBYINfdBeOGqxhFx18ci257gz0YWC/Fpfc9aezso0ERSD+f6abC7s4u7B
FokdJ11RPEm9T0gsD9mEfDP2oOa9T14Yv9BhafVUBRgzfEMJCUUCVA==
=XleI
-----END PGP SIGNATURE-----