annotate tests/test-floorl-ieee.c @ 17921:58c1b50299a6

getopt: give accurate ambiguity diagnostic on mem exhaustion * lib/getopt.c (_getopt_internal_r): The previous commit broke out the loop too early, which could give a false indication of ambiguous options under memory exhaustion.
author Pádraig Brady <P@draigBrady.com>
date Wed, 18 Feb 2015 22:37:31 +0000
parents ab58d4870664
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of rounding towards negative infinity.
17848
ab58d4870664 version-etc: new year
Paul Eggert <eggert@cs.ucla.edu>
parents: 17587
diff changeset
2 Copyright (C) 2010-2015 Free Software Foundation, Inc.
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software: you can redistribute it and/or modify
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3 of the License, or
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 (at your option) any later version.
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <math.h>
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 #include "fpucw.h"
16424
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
22 #include "isnanl-nolibm.h"
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23 #include "minus-zero.h"
16424
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
24 #include "infinity.h"
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
25 #include "nan.h"
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include "macros.h"
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 int
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 main ()
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 {
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31 DECL_LONG_DOUBLE_ROUNDING
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33 BEGIN_LONG_DOUBLE_ROUNDING ();
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34
13991
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
35 /* See IEEE 754, section 6.3:
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
36 "the sign of the result of the round floating-point number to
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
37 integral value operation is the sign of the operand. These rules
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
38 shall apply even when operands or results are zero or infinite." */
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
39
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 /* Zero. */
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 ASSERT (!signbit (floorl (0.0L)));
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 ASSERT (!!signbit (floorl (minus_zerol)) == !!signbit (minus_zerol));
13991
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
43 /* Positive numbers. */
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
44 ASSERT (!signbit (floorl (0.3L)));
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
45 ASSERT (!signbit (floorl (0.7L)));
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
46 /* Negative numbers. */
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
47 ASSERT (!!signbit (floorl (-0.3L)) == !!signbit (minus_zerol));
525bc52bc59f floor: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13985
diff changeset
48 ASSERT (!!signbit (floorl (-0.7L)) == !!signbit (minus_zerol));
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49
16424
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
50 /* [MX] shaded specification in POSIX. */
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
51
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
52 /* NaN. */
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
53 ASSERT (isnanl (floorl (NaNl ())));
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
54 /* Infinity. */
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
55 ASSERT (floorl (Infinityl ()) == Infinityl ());
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
56 ASSERT (floorl (- Infinityl ()) == - Infinityl ());
321e99caa67f floorl-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
57
13985
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 return 0;
c9ccadf9d9c3 New module 'floorl-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 }