develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #133110] [powerpc64] perl prints subnormal doubledoublesincorrectly.

From:
Sisyphus
Date:
April 14, 2018 05:39
Subject:
[perl #133110] [powerpc64] perl prints subnormal doubledoublesincorrectly.
Message ID:
rt-4.0.24-26227-1523684390-1189.133110-75-0@perl.org
# New Ticket Created by  "Sisyphus" 
# Please include the string:  [perl #133110]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133110 >


Hi,

I'm running perl-5.27.10, but the same issue is evident in perl-5.20.0 and 
perl-5.26.0.

For perls built with -Duselongdouble on my powerpc64 box the 'long double' 
is a 'doubledouble'.
As an example of the problem:

$ perl -le 'print 2 ** -1074;'
4.450147717014402766180465434665e-308

But this is the same as 2 ** -1021:

$ perl -le 'print 2 ** -1021;'
4.450147717014402766180465434665e-308

Similarly for all other subnormals I tried, perl's print and printf( "%e", 
..) functions output values that are off by a factor of 2**53.
Using printf's "%a" formatting produces the correct result.

Also, we see that the value being held by the NV is correct when we unpack 
it:
$ perl -le ' print scalar reverse unpack "h*", pack "F<", 2 ** -1074;'
00000000000000010000000000000000

This is clearly the pair of doubles DBL_DENORM_MIN and zero - which is the 
smallest positive value that the doubledouble can hold.

Cheers,
Rob

$ perl -V
Summary of my perl5 (revision 5 version 27 subversion 10) configuration:

  Platform:
    osname=linux
    osvers=3.2.0-4-powerpc64
    archname=ppc64-linux-thread-multi-ld
    uname='linux debian-sis 3.2.0-4-powerpc64 #1 smp debian 3.2.78-1 ppc64 
gnulinux '
    config_args='-des -Uversiononly -Dcc=gcc -m64 -Dprefix=/home/sisyphus-sis/perl-5.27.10-ld 
 -Dusedevel -Duselongdouble -Dusethreads -Duse64bitint'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=define
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc -m64'
    ccflags 
='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector 
 -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O1'
    cppflags='-D_REENTRANT -D_GNU_SOURCE -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=87654321
    doublekind=4
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=6
    ivtype='long'
    ivsize=8
    nvtype='long double'
    nvsize=16
    Off_t='off_t'
    lseeksize=8
    alignbytes=16
    prototype=define
  Linker and Libraries:
    ld='gcc -m64'
    ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/powerpc-linux-gnu/4.6/include-fixed 
/usr/lib /lib/powerpc-linux-gnu /lib/../lib /usr/lib/powerpc-linux-gnu 
/usr/lib/../lib /lib /lib64 /usr/lib64
    libs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.13.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O1 -L/usr/local/lib -fstack-protector'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_ITHREADS
    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
    USE_REENTRANT_API
  Built under linux
  Compiled at Apr  3 2018 20:52:50
  @INC:
    /home/sisyphus-sis/perl-5.27.10-ld/lib/site_perl/5.27.10/ppc64-linux-thread-multi-ld
    /home/sisyphus-sis/perl-5.27.10-ld/lib/site_perl/5.27.10
    /home/sisyphus-sis/perl-5.27.10-ld/lib/5.27.10/ppc64-linux-thread-multi-ld
    /home/sisyphus-sis/perl-5.27.10-ld/lib/5.27.10




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About