1 /* Test of rounding to nearest, breaking ties away from zero.
2 Copyright (C) 2007-2010 Free Software Foundation, Inc.
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, or (at your option)
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.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
18 /* Written by Ben Pfaff <blp@gnu.org>, 2007.
19 Based heavily on Bruno Haible's test-truncl.c. */
25 #include "signature.h"
26 SIGNATURE_CHECK (roundl, long double, (long double));
31 #include "isnanl-nolibm.h"
32 #include "minus-zero.h"
39 DECL_LONG_DOUBLE_ROUNDING
41 BEGIN_LONG_DOUBLE_ROUNDING ();
44 ASSERT (roundl (0.0L) == 0.0L);
45 ASSERT (roundl (minus_zerol) == 0.0L);
46 /* Positive numbers. */
47 ASSERT (roundl (0.3L) == 0.0L);
48 ASSERT (roundl (0.5L) == 1.0L);
49 ASSERT (roundl (0.7L) == 1.0L);
50 ASSERT (roundl (1.0L) == 1.0L);
51 ASSERT (roundl (1.5L) == 2.0L);
52 ASSERT (roundl (2.5L) == 3.0L);
53 ASSERT (roundl (1.999L) == 2.0L);
54 ASSERT (roundl (2.0L) == 2.0L);
55 ASSERT (roundl (65535.999L) == 65536.0L);
56 ASSERT (roundl (65536.0L) == 65536.0L);
57 ASSERT (roundl (65536.001L) == 65536.0L);
58 ASSERT (roundl (2.341e31L) == 2.341e31L);
59 /* Negative numbers. */
60 ASSERT (roundl (-0.3L) == 0.0L);
61 ASSERT (roundl (-0.5L) == -1.0L);
62 ASSERT (roundl (-0.7L) == -1.0L);
63 ASSERT (roundl (-1.0L) == -1.0L);
64 ASSERT (roundl (-1.5L) == -2.0L);
65 ASSERT (roundl (-2.5L) == -3.0L);
66 ASSERT (roundl (-1.999L) == -2.0L);
67 ASSERT (roundl (-2.0L) == -2.0L);
68 ASSERT (roundl (-65535.999L) == -65536.0L);
69 ASSERT (roundl (-65536.0L) == -65536.0L);
70 ASSERT (roundl (-65536.001L) == -65536.0L);
71 ASSERT (roundl (-2.341e31L) == -2.341e31L);
72 /* Infinite numbers. */
73 ASSERT (roundl (1.0 / 0.0L) == 1.0 / 0.0L);
74 ASSERT (roundl (-1.0 / 0.0L) == -1.0 / 0.0L);
76 ASSERT (isnanl (roundl (NaNl ())));