annotate tests/test-roundf-ieee.c @ 17363:5a51fb7777a9

sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin Problem reported by Marco Atzeri in <http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>. * lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]: Simply delegate to the system <sys/select.h> in this case too. Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to be needed on Solaris either. * lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]: Simply delgate to the system <sys/time.h> in this case.
author Paul Eggert <eggert@cs.ucla.edu>
date Tue, 19 Mar 2013 09:08:47 -0700
parents e542fd46ad6f
children 344018b6e5d7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Test of rounding to nearest, breaking ties away from zero.
17249
e542fd46ad6f maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents: 16431
diff changeset
2 Copyright (C) 2010-2013 Free Software Foundation, Inc.
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4 This program is free software; you can redistribute it and/or modify
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
5 it under the terms of the GNU General Public License as published by
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 the Free Software Foundation; either version 3, or (at your option)
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
7 any later version.
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
8
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 GNU General Public License for more details.
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
16366
bb182ee4a09d maint: replace FSF snail-mail addresses with URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 16201
diff changeset
15 along with this program; if not, see <http://www.gnu.org/licenses/>. */
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
16
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17 #include <config.h>
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
19 #include <math.h>
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
16431
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
21 #include "isnanf-nolibm.h"
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include "minus-zero.h"
16431
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
23 #include "infinity.h"
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
24 #include "nan.h"
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include "macros.h"
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
27 int
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28 main ()
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
29 {
13994
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
30 /* See IEEE 754, section 6.3:
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
31 "the sign of the result of the round floating-point number to
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
32 integral value operation is the sign of the operand. These rules
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
33 shall apply even when operands or results are zero or infinite." */
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
34
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35 /* Zero. */
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36 ASSERT (!signbit (roundf (0.0f)));
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 ASSERT (!!signbit (roundf (minus_zerof)) == !!signbit (minus_zerof));
13994
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
38 /* Positive numbers. */
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
39 ASSERT (!signbit (roundf (0.3f)));
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
40 ASSERT (!signbit (roundf (0.7f)));
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
41 /* Negative numbers. */
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
42 ASSERT (!!signbit (roundf (-0.3f)) == !!signbit (minus_zerof));
b91bc81df379 round: Implement result sign according to IEEE 754.
Bruno Haible <bruno@clisp.org>
parents: 13980
diff changeset
43 ASSERT (!!signbit (roundf (-0.7f)) == !!signbit (minus_zerof));
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44
16431
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
45 /* [MX] shaded specification in POSIX. */
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
46
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
47 /* NaN. */
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
48 ASSERT (isnanf (roundf (NaNf ())));
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
49 /* Infinity. */
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
50 ASSERT (roundf (Infinityf ()) == Infinityf ());
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
51 ASSERT (roundf (- Infinityf ()) == - Infinityf ());
f16e87d6bf2e roundf-ieee tests: More tests.
Bruno Haible <bruno@clisp.org>
parents: 16366
diff changeset
52
13980
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 return 0;
6eb5574f0333 New module 'roundf-ieee'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 }