This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix oct/bin fp fractions in non-HEXFP_UQUAD builds
authorZefram <zefram@fysh.org>
Wed, 6 Dec 2017 17:41:59 +0000 (17:41 +0000)
committerZefram <zefram@fysh.org>
Wed, 6 Dec 2017 17:41:59 +0000 (17:41 +0000)
The code for binaryish floating point literals, on builds where
we're not confident of being able to fit a significand into an
integer type, had built-in knowledge that the radix is 16, after
the radix point.  This gave erroneous values for octal and binary
literals on those builds.  This was shown up by the tests added in
commit 58be57636a42d6c6fd404c48c4e1cb87870182df.  Correct it to use the
actual radix.

toke.c

diff --git a/toke.c b/toke.c
index 60806a7..5aeec6f 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -11143,7 +11143,7 @@ Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
                             }
 #else /* HEXFP_NV */
                             if (accumulate) {
-                                nv_mult /= 16.0;
+                                nv_mult /= nvshift[shift];
                                 if (nv_mult > 0.0)
                                     hexfp_nv += b * nv_mult;
                                 else