ceil: Implement result sign according to IEEE 754.
[gnulib.git] / tests / test-ceill-ieee.c
index e7b541c..0e06c00 100644 (file)
@@ -29,9 +29,20 @@ main ()
 
   BEGIN_LONG_DOUBLE_ROUNDING ();
 
+  /* See IEEE 754, section 6.3:
+       "the sign of the result of the round floating-point number to
+        integral value operation is the sign of the operand. These rules
+        shall apply even when operands or results are zero or infinite."  */
+
   /* Zero.  */
   ASSERT (!signbit (ceill (0.0L)));
   ASSERT (!!signbit (ceill (minus_zerol)) == !!signbit (minus_zerol));
+  /* Positive numbers.  */
+  ASSERT (!signbit (ceill (0.3L)));
+  ASSERT (!signbit (ceill (0.7L)));
+  /* Negative numbers.  */
+  ASSERT (!!signbit (ceill (-0.3L)) == !!signbit (minus_zerol));
+  ASSERT (!!signbit (ceill (-0.7L)) == !!signbit (minus_zerol));
 
   return 0;
 }