Documentation for bignum is confusing or wrong.
Says:
EXAMPLES
Some cool command line examples to impress the Python crowd ;) You
might want to compare them to the results under -Mbignum or -Mbigrat:
perl -Mbigint -le 'print sqrt(33)'
perl -Mbigint -le 'print 2*255'
perl -Mbigint -le 'print 4.5+2*255'
perl -Mbigint -le 'print 3/7 + 5/7 + 8/3'
perl -Mbigint -le 'print 123->is_odd()'
perl -Mbigint -le 'print log(2)'
perl -Mbigint -le 'print 2 ** 0.5'
perl -Mbigint=a,65 -le 'print 2 ** 0.2'
perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
I run these and get:
Show quoted text
> perl -Mbigint -le 'print sqrt(33)'
5
Show quoted text> perl -Mbigint -le 'print 2*255'
510
Show quoted text> perl -Mbigint -le 'print 4.5+2*255'
514
Show quoted text> perl -Mbigint -le 'print 3/7 + 5/7 + 8/3'
2
Show quoted text> perl -Mbigint -le 'print 123->is_odd()'
1
Show quoted text> perl -Mbigint -le 'print log(2)'
0
Show quoted text> perl -Mbigint -le 'print 2 ** 0.5'
1
Show quoted text> perl -Mbigint=a,65 -le 'print 2 ** 0.2'
1
Show quoted text> perl -Mbignum=a,65,l,GMP -le 'print 7 ** 7777'
"l" is not exported by the bignum module
Can't continue after import errors at /usr/lib/perl5/5.10.0/bignum.pm
line 232
BEGIN failed--compilation aborted.
How are any of these 'impressive?' 2*255 = 510? Wow!
510+4.5=514?
Isn't this the same as "use integer"?
"l" is not exported?
I don't see anything impressive about these examples.
They don't demonstrate big integers at all from what I can see.
Note it says to compare with using bigrat -- so I tried that as well:
perl -Mbigrat -le 'print sqrt(33)'
Segmentation fault (core dumped)
The
python folks will be overwhelmed!
My perl -V:
Summary of my perl5 (revision 5 version 10 subversion 0) configuration:
Platform:
osname=linux, osvers=2.6.31, archname=x86_64-linux-thread-multi
uname='linux build35 2.6.31 #1 smp 2010-01-06 16:07:25 +0100 x86_64
x86_64 x86_64 gnulinux '
config_args='-ds -e -Dprefix=/usr -Dvendorprefix=/usr
-Dinstallusrbinperl -Dusethreads -Di_db -Di_dbm -Di_ndbm -Di_gdbm
-Duseshrplib=true -DEBUGGING=both -Doptimize=-fmessage-length=0 -O2
-Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables
-fasynchronous-unwind-tables -Wall -pipe -Accflags=-DPERL_USE_SAFE_PUTENV'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV
-DDEBUGGING -fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-fmessage-length=0 -O2 -Wall -D_FORTIFY_SOURCE=2
-fstack-protector -funwind-tables -fasynchronous-unwind-tables -Wall
-pipe -g',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV
-DDEBUGGING -fno-strict-aliasing -pipe'
ccversion='', gccversion='4.4.1 [gcc-4_4-branch revision 150839]',
gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib64'
libpth=/lib64 /usr/lib64 /usr/local/lib64
libs=-lm -ldl -lcrypt -lpthread
perllibs=-lm -ldl -lcrypt -lpthread
libc=/lib64/libc-2.10.1.so, so=so, useshrplib=true, libperl=libperl.so
gnulibc_version='2.10.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib64'
Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_TRACK_MEMPOOL PERL_USE_SAFE_PUTENV
USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Sep 16 2010 16:21:22
@INC:
/usr/lib/perl5/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/5.10.0
/usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl