Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limited exponent range in hex fp literal with long double #15512

Closed
p5pRT opened this issue Aug 13, 2016 · 10 comments
Closed

limited exponent range in hex fp literal with long double #15512

p5pRT opened this issue Aug 13, 2016 · 10 comments

Comments

@p5pRT
Copy link
Collaborator

@p5pRT p5pRT commented Aug 13, 2016

Migrated from rt.perl.org#128919 (status was 'resolved')

Searchable as RT128919$

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 13, 2016

From zefram@fysh.org

Created by zefram@fysh.org

With x86 80-bit long double​:

$ perl -MData​::Float -lwe 'print 0x1p-1074'
4.94065645841246544e-324
$ perl -MData​::Float -lwe 'print 0x1p-1075'
0
$ perl -MData​::Float -lwe 'print 2**-1075'
2.47032822920623272e-324
$ perl -MData​::Float -lwe 'print 2**-16445'
3.6451995318824746e-4951

Observe that a hex floating point literal with exponent below -1074
yields a zero value, though -1074 was OK. As indicated by the subsequent
computations, much lower powers of two can actually be represented in
this floating point format. Hex literals ought to accept much lower
exponents accordingly.

What's special about -1074 is that 2**-1074 is the smallest power of
two representable in the native *double* format (not long double).
A double-typed pow() call is being used where an NV-typed computation
is required.

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl 5.24.0:

Configured by zefram at Mon May  9 19:42:55 BST 2016.

Summary of my perl5 (revision 5 version 24 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.16.0-4-amd64, archname=x86_64-linux-thread-multi-ld
    uname='linux barba.rous.org 3.16.0-4-amd64 #1 smp debian 3.16.7-ckt11-1+deb8u6 (2015-11-09) x86_64 gnulinux '
    config_args='-des -Dprefix=/home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63 -Duselargefiles -Dusethreads -Uafs -Ud_csh -Uusesfio -Uusenm -Duseshrplib -Dusedevel -Uversiononly -Ui_db -Duselongdouble'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=define
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion='', gccversion='4.9.2', 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-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/gcc/x86_64-linux-gnu/4.9/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 -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.19.so, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.19'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/lib/5.24.0/x86_64-linux-thread-multi-ld/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'



@INC for perl 5.24.0:
    /home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/lib/site_perl/5.24.0/x86_64-linux-thread-multi-ld
    /home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/lib/site_perl/5.24.0
    /home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/lib/5.24.0/x86_64-linux-thread-multi-ld
    /home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/lib/5.24.0
    .


Environment for perl 5.24.0:
    HOME=/home/zefram
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/zefram/usr/perl/perl_install/perl-5.24.0-i64-f63/bin:/home/zefram/usr/perl/util:/home/zefram/pub/x86_64-unknown-linux-gnu/bin:/home/zefram/pub/common/bin:/usr/bin:/bin:/usr/local/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/usr/bin/zsh

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 13, 2016

From @sisyphus

-----Original Message-----
From​: Zefram (via RT)
Sent​: Sunday, August 14, 2016 8​:14 AM
To​: bugs-bitbucket@​rt.perl.org
Subject​: [perl #128919] limited exponent range in hex fp literal with long
double

With x86 80-bit long double​:

$ perl -MData​::Float -lwe 'print 0x1p-1074'
4.94065645841246544e-324
$ perl -MData​::Float -lwe 'print 0x1p-1075'
0

With perl 5, version 24, subversion 0 (v5.24.0) built for
MSWin32-x64-multi-thread-ld I see the same behaviour.

However, with perl 5, version 24, subversion 0 (v5.24.0) built for
MSWin32-x86-multi-thread-64int-ld there's no such problem​:

C​:\>perl -lwe "print 0x1p-1074"
4.94065645841246544e-324

C​:\>perl -lwe "print 0x1p-1075"
2.47032822920623272e-324

C​:\>perl -lwe "print 0x1p-1076"
1.23516411460311636e-324

Cheers,
Rob

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 13, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 13, 2016

From zefram@fysh.org

sisyphus1@​optusnet.com.au wrote​:

However, with perl 5, version 24, subversion 0 (v5.24.0) built for
MSWin32-x86-multi-thread-64int-ld there's no such problem​:

Weird. Perhaps double on that platform is actually the 80-bit type?
Please show us the perl -V for both of the builds you mentioned.

-zefram

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 14, 2016

From @sisyphus

-----Original Message-----
From​: Zefram
Sent​: Sunday, August 14, 2016 9​:55 AM
To​: perl5-porters@​perl.org
Subject​: Re​: [perl #128919] limited exponent range in hex fp literal with
long double

sisyphus1@​optusnet.com.au wrote​:

However, with perl 5, version 24, subversion 0 (v5.24.0) built for
MSWin32-x86-multi-thread-64int-ld there's no such problem​:

Weird. Perhaps double on that platform is actually the 80-bit type?

No. "Double" is the normal 64-bit type.
Incidentally, the same behaviour goes back to 5.22.0 (which was the first
stable release of Windows perl to support 'long double' NVs).

I've a vague notion that there might be some relevant mingw-specific stuff
being done wrt a mingw powl bug ... but I haven't been able to dig it up
(and my memory is not of much use).
Tony or Jarkko might have a better recollection of it (or at least a better
idea of where to look for it).

Please show us the perl -V for both of the builds you mentioned.

Both builds have the 80-bit extended precision 'long double' as the NV -
though, as you'll notice, they report different 'nvsize' values.

For the 64-bit build (which exhibits the problem)​:

################################################
Summary of my perl5 (revision 5 version 24 subversion 0) configuration​:

  Platform​:
  osname=MSWin32, osvers=6.1, archname=MSWin32-x64-multi-thread-ld
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  useithreads=define, usemultiplicity=define
  use64bitint=define, use64bitall=undef, uselongdouble=define
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='gcc', ccflags
' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing
-mms-bitfields',
  optimize='-s -O2',
  cppflags='-DWIN32'
  ccversion='', gccversion='5.3.0', gccosandvers=''
  intsize=4, longsize=4, ptrsize=8, doublesize=8, byteorder=12345678,
doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16,
longdblkind=3
  ivtype='long long', ivsize=8, nvtype='long double', nvsize=16,
Off_t='long long', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='g++', ldflags
='-s -L"c​:\_64\perl524_530_ld\lib\CORE" -L"C​:\_64\gcc-mingw-530\mingw64\lib"'
  libpth=C​:\_64\gcc-mingw-530\mingw64\lib C​:\_64\gcc-mingw-530\mingw64\lib
C​:\_64\gcc-mingw-530\mingw64\x86_64-w64-mingw32\lib
C​:\_64\msys_530\1.0\local\lib
C​:\_64\gcc-mingw-530\mingw64\lib\gcc\x86_64-w64-mingw32\5.3.0
  libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  libc=, so=dll, useshrplib=true, libperl=libperl524.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ',
lddlflags='-mdll -s -L"c​:\_64\perl524_530_ld\lib\CORE" -L"C​:\_64\gcc-mingw-530\mingw64\lib"'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY
  PERLIO_LAYERS PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
  PERL_MALLOC_WRAP PERL_PRESERVE_IVUV 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
  Built under MSWin32
  Compiled at May 9 2016 22​:42​:52
  @​INC​:
  C​:/_64/perl524_530_ld/site/lib
  C​:/_64/perl524_530_ld/lib
  .
################################################

For the 32-bit build (which does not exhibit the problem)​:

################################################
Summary of my perl5 (revision 5 version 24 subversion 0) configuration​:

  Platform​:
  osname=MSWin32, osvers=6.1, archname=MSWin32-x86-multi-thread-64int-ld
  uname=''
  config_args='undef'
  hint=recommended, useposix=true, d_sigaction=undef
  useithreads=define, usemultiplicity=define
  use64bitint=define, use64bitall=undef, uselongdouble=define
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='gcc', ccflags
=' -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS
-DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields',
  optimize='-s -O2',
  cppflags='-DWIN32'
  ccversion='', gccversion='5.3.0', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=12345678,
doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12,
longdblkind=3
  ivtype='long long', ivsize=8, nvtype='long double', nvsize=12,
Off_t='long long', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='g++', ldflags
='-s -L"c​:\MinGW\perl524_64int_ld\lib\CORE" -L"C​:\_32\gcc-mingw-530\mingw32\lib"'
  libpth=C​:\_32\gcc-mingw-530\mingw32\lib C​:\_32\gcc-mingw-530\mingw32\lib
C​:\_32\gcc-mingw-530\mingw32\i686-w64-mingw32\lib
C​:\_32\msys_530\1.0\local\lib
C​:\_32\gcc-mingw-530\mingw32\lib\gcc\i686-w64-mingw32\5.3.0
  libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32
-lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion
-lodbc32 -lodbccp32 -lcomctl32
  libc=, so=dll, useshrplib=true, libperl=libperl524.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ',
lddlflags='-mdll -s -L"c​:\MinGW\perl524_64int_ld\lib\CORE" -L"C​:\_32\gcc-mingw-530\mingw32\lib"'

Characteristics of this binary (from libperl)​:
  Compile-time options​: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY
  PERLIO_LAYERS PERL_COPY_ON_WRITE
  PERL_DONT_CREATE_GVSV
  PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
  PERL_MALLOC_WRAP PERL_PRESERVE_IVUV 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
  Built under MSWin32
  Compiled at May 9 2016 22​:40​:49
  @​INC​:
  C​:/MinGW/perl524_64int_ld/site/lib
  C​:/MinGW/perl524_64int_ld/lib
  .
################################################

Cheers,
Rob

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 14, 2016

From @dcollinsn

I noticed that Jarkko committed the following to blead​:

Branch​: blead
Patch​: a149d11
Author​: Jarkko Hietaniemi <jhi@​iki.fi>
Commit summary​: [perl #128919] limited exponent range in hex fp literal with long double

However, the following tests fail on quadmath builds​:

  # Failed test 106 - at op/hexfp.t line 250
  # got "4.94065645841246544176568792868221e-324"
  # expected "4.94065645841246544e-324"
  # Failed test 107 - [perl \#128919] at op/hexfp.t line 251
  # got "2.47032822920623272088284396434111e-324"
  # expected "2.47032822920623272e-324"
  # Failed test 108 - at op/hexfp.t line 252
  # got "1.23516411460311636044142198217055e-324"
  # expected "1.23516411460311636e-324"
  t/op/hexfp ..................................................... FAILED at test 106

I'll copy him, since he's already done work on this ticket.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 14, 2016

From [Unknown Contact. See original ticket]

I noticed that Jarkko committed the following to blead​:

Branch​: blead
Patch​: a149d11
Author​: Jarkko Hietaniemi <jhi@​iki.fi>
Commit summary​: [perl #128919] limited exponent range in hex fp literal with long double

However, the following tests fail on quadmath builds​:

  # Failed test 106 - at op/hexfp.t line 250
  # got "4.94065645841246544176568792868221e-324"
  # expected "4.94065645841246544e-324"
  # Failed test 107 - [perl \#128919] at op/hexfp.t line 251
  # got "2.47032822920623272088284396434111e-324"
  # expected "2.47032822920623272e-324"
  # Failed test 108 - at op/hexfp.t line 252
  # got "1.23516411460311636044142198217055e-324"
  # expected "1.23516411460311636e-324"
  t/op/hexfp ..................................................... FAILED at test 106

I'll copy him, since he's already done work on this ticket.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 14, 2016

From @jhi

http​://perl5.git.perl.org/perl.git/commitdiff/7301378635b35757b228e07c14276afaf06a4728

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 23, 2016

From @jhi

Marking resolved until proven otherwise.

@p5pRT

This comment has been minimized.

Copy link
Collaborator Author

@p5pRT p5pRT commented Aug 23, 2016

@jhi - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.