This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hexfp: printf %.13a 1.0
authorJarkko Hietaniemi <jhi@iki.fi>
Sun, 29 Nov 2015 03:22:25 +0000 (22:22 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Sun, 29 Nov 2015 14:51:59 +0000 (09:51 -0500)
sv.c
t/op/sprintf2.t

diff --git a/sv.c b/sv.c
index 53133b9..d080f1f 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12449,8 +12449,8 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
                     *p++ = xdig[*v++];
 
                     /* The radix is always output after the first
-                     * non-zero xdigit, or if alt.  */
-                    if (vfnz < vlnz || alt) {
+                     * non-zero xdigit, or if precis, or if alt.  */
+                    if (vfnz < vlnz || precis > 0 || alt) {
 #ifndef USE_LOCALE_NUMERIC
                         *p++ = '.';
 #else
index 6aa994c..1f0c515 100644 (file)
@@ -67,6 +67,9 @@ if ($Config{nvsize} == 8 &&
         [ '% 20.10a', '3.14',   '   0x1.91eb851eb8p+1' ],
         [ '%020.10a', '3.14',   '0x0001.91eb851eb8p+1' ],
 
+        [ '%.13a',    '1',   '0x1.0000000000000p+0' ],
+        [ '%.13a',    '-1',  '-0x1.0000000000000p+0' ],
+
         [ '%30a',  '3.14',   '          0x1.91eb851eb851fp+1' ],
         [ '%-30a', '3.14',   '0x1.91eb851eb851fp+1          ' ],
         [ '%030a',  '3.14',  '0x00000000001.91eb851eb851fp+1' ],