This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hexfp: signbit() works on NVs (nv), not on long doubles (fv).
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 30 Nov 2015 12:27:47 +0000 (07:27 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 1 Dec 2015 14:07:14 +0000 (09:07 -0500)
The nv value should be a valid version of the fv value.

Why the fv is a long double, not a NV, is a long (haha) story.
Short version: the printf code expects to be able to work with long
doubles, if long doubles are available, even without -Duselongdouble.

The problem became obvious in VMS which has true 128-bit long
(little-endian) doubles, and trying the signbit() on those did
not work.

sv.c

diff --git a/sv.c b/sv.c
index 79b8a50..f36a724 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12366,7 +12366,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
 #endif
 
                 if (fv < 0
-                    || Perl_signbit(fv)
+                    || Perl_signbit(nv)
                   )
                     *p++ = '-';
                 else if (plus)