diff --git a/sv.c b/sv.c index 93e636407101..ac41af27dfe9 100644 --- a/sv.c +++ b/sv.c @@ -12510,7 +12510,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p v0 = vhex; } - if (precis > 0) { + if (has_precis) { U8* ve = (subnormal ? vlnz + 1 : vend); SSize_t vn = ve - (subnormal ? vfnz : vhex); if ((SSize_t)(precis + 1) < vn) { diff --git a/t/op/sprintf2.t b/t/op/sprintf2.t index f53dd8365fc9..0f99fd36ff87 100644 --- a/t/op/sprintf2.t +++ b/t/op/sprintf2.t @@ -262,7 +262,7 @@ if ($Config{nvsize} == 8 && print "# no hexfloat tests\n"; } -plan tests => 1408 + ($Q ? 0 : 12) + @hexfloat + 37; +plan tests => 1408 + ($Q ? 0 : 12) + @hexfloat + 40; use strict; use Config; @@ -802,3 +802,8 @@ SKIP: { is($s, $t->[2], "subnormal @$t got $s"); } } + +# [rt.perl.org #128888] +is(sprintf("%a", 1.03125), "0x1.08p+0"); +is(sprintf("%.1a", 1.03125), "0x1.0p+0"); +is(sprintf("%.0a", 1.03125), "0x1p+0", "[rt.perl.org #128888]");