This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
hexfp: Use Perl_fp_class_nzero unconditionally.
authorJarkko Hietaniemi <jhi@iki.fi>
Fri, 4 Dec 2015 23:22:30 +0000 (18:22 -0500)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 5 Dec 2015 02:28:06 +0000 (21:28 -0500)
Otherwise in platforms with Perl_fp_class_nzero there would be no
return for the x != 0.0 case.

numeric.c

index 9cf6f6f..f1de219 100644 (file)
--- a/numeric.c
+++ b/numeric.c
@@ -1630,11 +1630,9 @@ Users should just always call C<Perl_signbit()>.
 int
 Perl_signbit(NV x) {
 #  ifdef Perl_fp_class_nzero
-    if (x == 0)
-        return Perl_fp_class_nzero(x);
-    /* Try finding the high byte, and assume it's highest
-     * bit is the sign.  This assumption is probably wrong
-     * somewhere. */
+    return Perl_fp_class_nzero(x);
+    /* Try finding the high byte, and assume it's highest bit
+     * is the sign.  This assumption is probably wrong somewhere. */
 #  elif defined(USE_LONG_DOUBLE) && LONG_DOUBLEKIND == LONG_DOUBLE_IS_X86_80_BIT_LITTLE_ENDIAN
     return (((unsigned char *)&x)[9] & 0x80);
 #  elif defined(NV_LITTLE_ENDIAN)
@@ -1645,7 +1643,7 @@ Perl_signbit(NV x) {
 #  elif defined(NV_BIG_ENDIAN)
     return (((unsigned char *)&x)[0] & 0x80);
 #  else
-    /* This last fallback will fail for the negative zero. */
+    /* This last resort fallback is wrong for the negative zero. */
     return (x < 0.0) ? 1 : 0;
 #  endif
 }