Mercurial > hg > octave-jordi > gnulib-hg
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 |
rev | line source |
---|---|
13985 | 1 /* Test of rounding towards negative infinity. |
17848 | 2 Copyright (C) 2010-2015 Free Software Foundation, Inc. |
13985 | 3 |
4 This program is free software: you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 3 of the License, or | |
7 (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */ | |
16 | |
17 #include <config.h> | |
18 | |
19 #include <math.h> | |
20 | |
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 | 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 | 26 #include "macros.h" |
27 | |
28 int | |
29 main () | |
30 { | |
31 DECL_LONG_DOUBLE_ROUNDING | |
32 | |
33 BEGIN_LONG_DOUBLE_ROUNDING (); | |
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 | 40 /* Zero. */ |
41 ASSERT (!signbit (floorl (0.0L))); | |
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 | 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 | 58 return 0; |
59 } |