Front page | perl.perl5.porters |
Postings from February 2000
[ID 20000229.007] printf() does not respect use integer,big numbers lose precision
Thread Next
From:
dhd
Date:
February 29, 2000 16:50
Subject:
[ID 20000229.007] printf() does not respect use integer,big numbers lose precision
Message ID:
E12PxKi-0000Ye-00@doppelbock.thepuffingroup.com
This is a bug report for perl from dhuggins@linuxcare.com,
generated with the help of perlbug 1.26 running under perl 5.00503.
-----------------------------------------------------------------
[Please enter your report here]
On my DEC Alpha, this program:
#!/usr/bin/perl
use integer;
$bigquad = pack "VV", 0xc5ac9b81, 0xc998806b;
printf "%016lx %08x %08x\n", (unpack "Q", $bigquad), (unpack "VV", $bigquad)
__END__
prints this:
c998806bc5ac9800 c5ac9b81 c998806b
Unfortunately it's not possible to reproduce this on 32-bit systems.
However the cause of it is pretty clear - the integer returned by
unpack "Q" is being "upgraded" to a floating poing number by printf(),
but since 'double' and 'long' types are both 64 bits on Alpha, it loses
precision when it gets converted to a floating-point number.
It's definitely printf and not unpack, as you can see here:
[dhd@doppelbock]:~$ perl -Minteger -e 'printf "%016lx\n", 0xc998806bc5ac9b81'
c998806bc5ac9800
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Site configuration information for perl 5.00503:
Configured by chris at Wed Jan 26 22:28:31 EST 2000.
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
Platform:
osname=linux, osvers=2.2.14pre9, archname=alpha-linux
uname='linux spawn 2.2.14pre9 #2 wed dec 15 00:24:37 est 1999 alpha unknown '
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O2 -mieee', gccversion=2.95.2 20000116 (Debian GNU/Linux)
cppflags='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
ccflags ='-Dbool=char -DHAS_BOOL -D_REENTRANT -DDEBIAN -I/usr/local/include'
stdchar='char', d_stdstdio=undef, usevfork=false
intsize=4, longsize=8, ptrsize=8, doublesize=8
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldbm -ldb -ldl -lm -lc -lposix -lcrypt
libc=, so=so, useshrplib=false, libperl=libperl.a
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 5.00503:
/usr/lib/perl5/5.005/alpha-linux
/usr/lib/perl5/5.005
/usr/local/lib/site_perl/alpha-linux
/usr/local/lib/site_perl
/usr/lib/perl5
.
---
Environment for perl 5.00503:
HOME=/home/dhd
LANG=en_CA
LANGUAGE (unset)
LD_LIBRARY_PATH (unset)
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Next
-
[ID 20000229.007] printf() does not respect use integer,big numbers lose precision
by dhd