develooper Front page | perl.perl5.porters | Postings from May 2015

[perl #124433] float calc. strangeness in 5.21.11-ld

Thread Previous | Thread Next
From:
Victor Efimov
Date:
May 1, 2015 11:02
Subject:
[perl #124433] float calc. strangeness in 5.21.11-ld
Message ID:
rt-4.0.18-20478-1430478134-30.124433-75-0@perl.org
# New Ticket Created by  Victor Efimov 
# Please include the string:  [perl #124433]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=124433 >


$ cat strange_thing_my.pl
use Devel::Peek;
use POSIX qw/floor ceil/;
my $sum = 0.002*1000;
my $s2 = int($sum/100);
print "sum is $sum, s2 is $s2\n";
print "floor( sum - (s2 * 100) ) is ";
my $sx = floor($sum - ($s2*100));
print "$sx\n";


----------------------
$ perlbrew exec --with perl-5.21.11 perl strange_thing_my.pl
perl-5.21.11
==========
sum is 2, s2 is 0
floor( sum - (s2 * 100) ) is 2


$ perlbrew exec --with perl-5.21.11-ld perl strange_thing_my.pl
perl-5.21.11-ld
==========
sum is 2, s2 is 0
floor( sum - (s2 * 100) ) is 1


$ perlbrew exec --with perl-5.21.2-ld perl strange_thing_my.pl
perl-5.21.2-ld
==========
sum is 2, s2 is 0
floor( sum - (s2 * 100) ) is 2
----------------------

problem that in perl-5.21.11-ld floor( sum - (s2 * 100) ) is 1, not 2.
is this a bug?
found in http://www.cpantesters.org/cpan/report/1e041e66-ede9-11e4-93de-b9891b12eb46


perl-5.21.11-ld
==========
Summary of my perl5 (revision 5 version 21 subversion 11) configuration:

  Platform:
    osname=linux, osvers=3.13.0-49-generic, archname=x86_64-linux-ld
    uname='linux green-u 3.13.0-49-generic #81~precise1-ubuntu smp wed
mar 25 16:32:15 utc 2015 x86_64 x86_64 x86_64 gnulinux '
    config_args='-de -Dprefix=/home/perlbrew/perls/perl-5.21.11-ld
-Duselongdouble -Dusedevel
-Aeval:scriptdir=/home/perlbrew/perls/perl-5.21.11-ld/bin'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fwrapv -fno-strict-aliasing -pipe
-fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector
-I/usr/local/include'
    ccversion='', gccversion='4.6.3', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8,
byteorder=12345678, doublekind=3
    d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=16, longdblkind=3
    ivtype='long', ivsize=8, nvtype='long double', nvsize=16,
Off_t='off_t', lseeksize=8
    alignbytes=16, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib
/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed
/usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu
/lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lpthread -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib
-fstack-protector'


Characteristics of this binary (from libperl):
  Compile-time options: HAS_TIMES PERLIO_LAYERS PERL_DONT_CREATE_GVSV
                        PERL_HASH_FUNC_ONE_AT_A_TIME_HARD PERL_MALLOC_WRAP
                        PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV
                        PERL_USE_DEVEL USE_64_BIT_ALL USE_64_BIT_INT
                        USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE
                        USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME
                        USE_LONG_DOUBLE USE_PERLIO USE_PERL_ATOF
  Built under linux
  Compiled at May  1 2015 13:35:33
  %ENV:
    PERL5LIB=""
    PERLBREW_BASHRC_VERSION="0.69"
    PERLBREW_HOME="/home/vse/.perlbrew"
    PERLBREW_MANPATH="/home/perlbrew/perls/perl-5.21.11-ld/man"
    PERLBREW_PATH="/home/perlbrew/bin:/home/perlbrew/perls/perl-5.21.11-ld/bin"
    PERLBREW_PERL="perl-5.21.11-ld"
    PERLBREW_ROOT="/home/perlbrew"
    PERLBREW_VERSION="0.69"
  @INC:
    /home/perlbrew/perls/perl-5.21.11-ld/lib/site_perl/5.21.11/x86_64-linux-ld
    /home/perlbrew/perls/perl-5.21.11-ld/lib/site_perl/5.21.11
    /home/perlbrew/perls/perl-5.21.11-ld/lib/5.21.11/x86_64-linux-ld
    /home/perlbrew/perls/perl-5.21.11-ld/lib/5.21.11
    .


Thread Previous | 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