develooper Front page | perl.perl5.porters | Postings from February 2009

[perl #63304] wrong calculating with floating point

Thread Next
February 18, 2009 15:54
[perl #63304] wrong calculating with floating point
Message ID:
# New Ticket Created by 
# Please include the string:  [perl #63304]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.35 running under perl v5.8.8.

[Please enter your report here]

# perl -d

Loading DB routines from version 1.28
Editor support available.


Enter h or `h h' for help, or `man perldebug' for more help.

Debugged program terminated.  Use q to quit or R to restart,
  use o inhibit_exit to avoid stopping after program termination,
  h q, h R or h o to get additional info.  
  DB<1> $a = 601; foreach $b (0..9) { $c = $a + $b / 10; print "$c: " . (($c * 100) - ($c * 10 * 10)) . "\n"; }
601: 0
601.1: 0
601.2: 7.27595761418343e-12
601.3: -7.27595761418343e-12
601.4: 0
601.5: 0
601.6: 0
601.7: 7.27595761418343e-12
601.8: -7.27595761418343e-12
601.9: 0


I found this error on:
- on Perl 5.8.8/FreeBSD 7.0 (this machine);
- on Perl 5.8.8/Linux gentoo (kernel 2.6.20-gentoo-r8);
- on Perl 5.8.8/Linux gentoo (kernel 2.4.32-gentoo-r7);
- on Perl 5.10.0/Linux Ubuntu 8.10 (kernel2.6.27-12-generic);

[Please do not change anything below this line]
Site configuration information for perl v5.8.8:

Configured by xore at Tue Sep 30 10:17:21 MSD 2008.

Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
    osname=freebsd, osvers=7.0-release, archname=i386-freebsd-thread-multi-64int
    uname='freebsd 7.0-release freebsd 7.0-release #0: sat may 17 16:48:34 petst 2008 root@rex.homenet2.amn:usrobjusrsrcsysgennew i386 '
    config_args='-sde -Dprefix=/usr/local -Darchlib=/usr/local/lib/perl5/5.8.8/mach -Dprivlib=/usr/local/lib/perl5/5.8.8 -Dman3dir=/usr/local/lib/perl5/5.8.8/perl/man/man3 -Dman1dir=/usr/local/man/man1 -Dsitearch=/usr/local/lib/perl5/site_perl/5.8.8/mach -Dsitelib=/usr/local/lib/perl5/site_perl/5.8.8 -Dscriptdir=/usr/local/bin -Dsiteman3dir=/usr/local/lib/perl5/5.8.8/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Ui_malloc -Ui_iconv -Uinstallusrbinperl -Dcc=cc -Duseshrplib -Dccflags=-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -Doptimize=-march=prescott -mtune=prescott -O2 -pipe -msse -msse2 -msse3 -march=prescott -fno-strict-aliasing -Dd_dosuid=define -Ui_gdbm -Dusethreads=y -Dusemymalloc=n -Duse64bitint'
    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=define use64bitall=undef uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include',
    optimize='-march=prescott -mtune=prescott -O2 -pipe -msse -msse2 -msse3 -march=prescott -fno-strict-aliasing',
    cppflags='-DAPPLLIB_EXP="/usr/local/lib/perl5/5.8.8/BSDPAN" -DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include'
    ccversion='', gccversion='4.2.1 20070719  [FreeBSD]', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-pthread -Wl,-E -L/usr/local/lib'
    libpth=/usr/lib /usr/local/lib
    libs=-lm -lcrypt -lutil
    perllibs=-lm -lcrypt -lutil
    libc=, so=so, useshrplib=true,
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='  -Wl,-R/usr/local/lib/perl5/5.8.8/mach/CORE'
    cccdlflags='-DPIC -fPIC', lddlflags='-shared  -L/usr/local/lib'

Locally applied patches:

@INC for perl v5.8.8:

Environment for perl v5.8.8:
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About