Mercurial > hg > octave-jordi > gnulib-hg
diff tests/test-floorl-ieee.c @ 13991:525bc52bc59f
floor: Implement result sign according to IEEE 754.
* lib/floor.c (FUNC): Return +0.0 for 0 < x < 1.
* tests/test-floor2.c (floor_reference): Keep in sync with lib/floor.c.
* tests/test-floorf2.c (floorf_reference): Likewise.
* tests/test-floorf-ieee.c (main): Test also values between -1 and 1.
* tests/test-floor-ieee.c (main): Likewise.
* tests/test-floorl-ieee.c (main): Likewise.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 22 Dec 2010 16:05:29 +0100 (2010-12-22) |
parents | c9ccadf9d9c3 |
children | 97fc9a21a8fb |
line wrap: on
line diff
--- a/tests/test-floorl-ieee.c +++ b/tests/test-floorl-ieee.c @@ -29,9 +29,20 @@ 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 (floorl (0.0L))); ASSERT (!!signbit (floorl (minus_zerol)) == !!signbit (minus_zerol)); + /* Positive numbers. */ + ASSERT (!signbit (floorl (0.3L))); + ASSERT (!signbit (floorl (0.7L))); + /* Negative numbers. */ + ASSERT (!!signbit (floorl (-0.3L)) == !!signbit (minus_zerol)); + ASSERT (!!signbit (floorl (-0.7L)) == !!signbit (minus_zerol)); return 0; }