Repository navigation
Non-canonical hexadecimal floats are parsed prematurely #15120
Description
Activity
From dankogai@dan.co.jp
Created by dankogai@dan-imac151.local
I am so glad Perl 5.22 adds support to the C99 hexadecimal floating point notation. What I am not so glad is I found that perl sometimes parses hex floats prematurely.
% perl -E 'say sprintf "%a", 0x0.b17217f7d1cf78p0 - 0x1.62e42fefa39efp-1'
-0x1p-53As you see, LHS is non-normal form and RHS normal. AFAIK in other platforms that support hexfloats 0x0.b17217f7d1cf78p0 == 0x1.62e42fefa39efp-1:
C:
http://ideone.com/Q0kbTL
C++:
http://ideone.com/j3odtE
Ruby:
http://ideone.com/VPj3Ie
Swift:
http://swiftlang.ng.bluemix.net/#/repl/2e2ccb20e8e262f8f54dc7e8af7fda9511f526198c1e71584bd17029616c3cf6Dan the Bit-Picking Perl Monger
Perl Info
Flags: category=core severity=medium Site configuration information for perl 5.22.1: Configured by dankogai at Thu Dec 17 00:32:07 JST 2015. Summary of my perl5 (revision 5 version 22 subversion 1) configuration: Platform: osname=darwin, osvers=15.2.0, archname=darwin-thread-multi-2level uname='darwin dan-imac151.local 15.2.0 darwin kernel version 15.2.0: fri nov 13 19:56:56 pst 2015; root:xnu-3248.20.55~2release_x86_64 x86_64 ' config_args='-DDEBUGGING -Doptimize=-g -pipe -Os -Accflags=-DPERL_USE_SAFE_PUTENV -Duseshplib -Dusethreads -Dusemultiplicity -Duse64bitall -des' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -arch x86_64 -DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/opt/local/include', optimize='-g -pipe -Os', cppflags='-arch x86_64 -fno-common -DPERL_DARWIN -arch x86_64 -DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/opt/local/include' ccversion='', gccversion='4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)', 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='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc -arch x86_64', ldflags =' -arch x86_64 -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib' libpth=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.2/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /usr/lib /usr/local/lib /opt/local/lib libs=-lpthread -lgdbm -ldbm -ldl -lm -lutil -lc perllibs=-lpthread -ldl -lm -lutil -lc libc=, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector-strong' @INC for perl 5.22.1: /usr/local/lib/perl5/site_perl/5.22.1/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.22.1 /usr/local/lib/perl5/5.22.1/darwin-thread-multi-2level /usr/local/lib/perl5/5.22.1 /usr/local/lib/perl5/site_perl/5.22.0/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.22.0 /usr/local/lib/perl5/site_perl . Environment for perl 5.22.1: DYLD_LIBRARY_PATH (unset) HOME=/Users/dankogai LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/Users/dankogai/sbin:/Users/dankogai/bin:/Users/dankogai/.rakudobrew/bin:/Users/dankogai/node_modules/.bin:/usr/local/bin:/opt/local/sbin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PERL_BADLANG (unset) SHELL=/bin/tcshFrom @sisyphus
-----Original Message-----
From: Dan Kogai (via RT)
Sent: Wednesday, January 06, 2016 10:57 PM
To: bugs-bitbucket@rt.perl.org
Subject: [perl #127183] Non-canonical hexadecimal floats are parsed
prematurelyThis is a bug report for perl from dankogai@dan-imac151.local,
generated with the help of perlbug 1.40 running under perl 5.22.1.% perl -E 'say sprintf "%a", 0x0.b17217f7d1cf78p0 -
0x1.62e42fefa39efp-1'
-0x1p-53Works fine for me on MS Windows, perl-5.22.0:
C:\>perl -E "say sprintf '%a', 0x0.b17217f7d1cf78p0 - 0x1.62e42fefa39efp-1"
0x0p+0A regression ?
Cheers,
RobThe RT System itself - Status changed from 'new' to 'open'
From @jhi
If you can, please test the bleadperl at
http://perl5.git.perl.org/perl.git/commit/eba98284740b799def26803ebac340aaa8930437
Test the hexfp literals and the %a without mercy.
From @iabyn
On Thu, Jan 07, 2016 at 01:42:01PM +1100, sisyphus1@optusnet.com.au wrote:
-----Original Message----- From: Dan Kogai (via RT)
Sent: Wednesday, January 06, 2016 10:57 PM
To: bugs-bitbucket@rt.perl.org
Subject: [perl #127183] Non-canonical hexadecimal floats are parsed
prematurelyThis is a bug report for perl from dankogai@dan-imac151.local,
generated with the help of perlbug 1.40 running under perl 5.22.1.% perl -E 'say sprintf "%a", 0x0.b17217f7d1cf78p0 -
0x1.62e42fefa39efp-1'
-0x1p-53Works fine for me on MS Windows, perl-5.22.0:
C:\>perl -E "say sprintf '%a', 0x0.b17217f7d1cf78p0 - 0x1.62e42fefa39efp-1"
0x0p+0A regression ?
the maint-5.22 branch now prints 0x0p+0, as well as perl-5.23.0 onwards.
So I think this ticket can be closed.--
"But Sidley Park is already a picture, and a most amiable picture too.
The slopes are green and gentle. The trees are companionably grouped at
intervals that show them to advantage. The rill is a serpentine ribbon
unwound from the lake peaceably contained by meadows on which the right
amount of sheep are tastefully arranged." -- Lady Croom, "Arcadia"@iabyn - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#127183 (status was 'resolved')
Searchable as RT127183$