Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: gcc/mpfr/tests/teint.c

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gcc/mpfr/tests/tdiv_ui.c ('k') | gcc/mpfr/tests/terf.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Test file for mpfr_eint.
2
3 Copyright 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
4 Contributed by the Arenaire and Cacao projects, INRIA.
5
6 This file is part of the GNU MPFR Library.
7
8 The GNU MPFR Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
11 option) any later version.
12
13 The GNU MPFR Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with the GNU MPFR Library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
21 MA 02110-1301, USA. */
22
23 #include <stdio.h>
24 #include <stdlib.h>
25
26 #include "mpfr-test.h"
27
28 #define TEST_FUNCTION mpfr_eint
29 #define TEST_RANDOM_POS 8
30 #define TEST_RANDOM_EMAX 40
31 #include "tgeneric.c"
32
33 static void
34 check_specials (void)
35 {
36 mpfr_t x, y;
37
38 mpfr_init2 (x, 123L);
39 mpfr_init2 (y, 123L);
40
41 mpfr_set_nan (x);
42 mpfr_eint (y, x, GMP_RNDN);
43 if (! mpfr_nan_p (y))
44 {
45 printf ("Error: eint(NaN) != NaN\n");
46 exit (1);
47 }
48
49 mpfr_set_inf (x, 1);
50 mpfr_eint (y, x, GMP_RNDN);
51 if (! (mpfr_inf_p (y) && mpfr_sgn (y) > 0))
52 {
53 printf ("Error: eint(+Inf) != +Inf\n");
54 exit (1);
55 }
56
57 mpfr_set_inf (x, -1);
58 mpfr_eint (y, x, GMP_RNDN);
59 if (! mpfr_nan_p (y))
60 {
61 printf ("Error: eint(-Inf) != NaN\n");
62 exit (1);
63 }
64
65 /* eint(+/-0) = -Inf */
66 mpfr_set_ui (x, 0, GMP_RNDN);
67 mpfr_eint (y, x, GMP_RNDN);
68 if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0))
69 {
70 printf ("Error: eint(+0) != -Inf\n");
71 exit (1);
72 }
73 mpfr_neg (x, x, GMP_RNDN);
74 mpfr_eint (y, x, GMP_RNDN);
75 if (! (mpfr_inf_p (y) && mpfr_sgn (y) < 0))
76 {
77 printf ("Error: eint(-0) != -Inf\n");
78 exit (1);
79 }
80
81 /* eint(x) = NaN for x < 0 */
82 mpfr_set_si (x, -1, GMP_RNDN);
83 mpfr_eint (y, x, GMP_RNDN);
84 if (! mpfr_nan_p (y))
85 {
86 printf ("Error: eint(-1) != NaN\n");
87 exit (1);
88 }
89
90 mpfr_set_prec (x, 17);
91 mpfr_set_prec (y, 17);
92 mpfr_set_str_binary (x, "1.0111110100100110e-2");
93 mpfr_set_str_binary (y, "-1.0010101001110100e-10");
94 mpfr_eint (x, x, GMP_RNDZ);
95 if (mpfr_cmp (x, y))
96 {
97 printf ("Error for x=1.0111110100100110e-2, GMP_RNDZ\n");
98 printf ("expected "); mpfr_dump (y);
99 printf ("got "); mpfr_dump (x);
100 exit (1);
101 }
102
103 mpfr_set_prec (x, 53);
104 mpfr_set_prec (y, 53);
105 mpfr_set_str_binary (x, "0.10E4");
106 mpfr_eint (x, x, GMP_RNDN);
107 mpfr_set_str (y, "440.37989953483827", 10, GMP_RNDN);
108 if (mpfr_cmp (x, y) != 0)
109 {
110 printf ("Error for x=0.10E4, GMP_RNDZ\n");
111 printf ("expected "); mpfr_dump (y);
112 printf ("got "); mpfr_dump (x);
113 exit (1);
114 }
115
116 mpfr_set_prec (x, 63);
117 mpfr_set_prec (y, 63);
118 mpfr_set_str_binary (x, "1.011111010111001110000110100010001011010110000110011 11101011010e-2");
119 mpfr_eint (x, x, GMP_RNDZ);
120 mpfr_set_str_binary (y, "1.110101100011010000010100100001000011110010001001000 00001011100e-17");
121 if (mpfr_cmp (x, y) != 0)
122 {
123 printf ("Error (1) for GMP_RNDZ\n");
124 printf ("expected "); mpfr_dump (y);
125 printf ("got "); mpfr_dump (x);
126 exit (1);
127 }
128
129 /* check large x */
130 mpfr_set_prec (x, 53);
131 mpfr_set_prec (y, 53);
132 mpfr_set_str_binary (x, "1E6");
133 mpfr_eint (x, x, GMP_RNDN);
134 mpfr_set_str_binary (y, "10100011110001101001110000110010111000100111010001E37 ");
135 if (mpfr_cmp (x, y) != 0)
136 {
137 printf ("Error for x=2^6, GMP_RNDN\n");
138 printf ("expected "); mpfr_dump (y);
139 printf ("got "); mpfr_dump (x);
140 exit (1);
141 }
142 mpfr_set_str_binary (x, "1E7");
143 mpfr_eint (x, x, GMP_RNDN);
144 mpfr_set_str_binary (y, "11001100100011110000101001011010110111111011110011E12 8");
145 if (mpfr_cmp (x, y) != 0)
146 {
147 printf ("Error for x=2^7, GMP_RNDN\n");
148 printf ("expected "); mpfr_dump (y);
149 printf ("got "); mpfr_dump (x);
150 exit (1);
151 }
152 mpfr_set_str_binary (x, "1E8");
153 mpfr_eint (x, x, GMP_RNDN);
154 mpfr_set_str_binary (y, "1010000110000101111111011011000101001000101011101001E 310");
155 if (mpfr_cmp (x, y) != 0)
156 {
157 printf ("Error for x=2^8, GMP_RNDN\n");
158 printf ("expected "); mpfr_dump (y);
159 printf ("got "); mpfr_dump (x);
160 exit (1);
161 }
162 mpfr_set_str_binary (x, "1E9");
163 mpfr_eint (x, x, GMP_RNDN);
164 mpfr_set_str_binary (y, "11001010101000001010101101110000010110011101110010101 E677");
165 if (mpfr_cmp (x, y) != 0)
166 {
167 printf ("Error for x=2^9, GMP_RNDN\n");
168 printf ("expected "); mpfr_dump (y);
169 printf ("got "); mpfr_dump (x);
170 exit (1);
171 }
172 mpfr_set_str_binary (x, "1E10");
173 mpfr_eint (x, x, GMP_RNDN);
174 mpfr_set_str_binary (y, "10011111111010010110110101101000101100101010101101101 E1415");
175 if (mpfr_cmp (x, y) != 0)
176 {
177 printf ("Error for x=2^10, GMP_RNDN\n");
178 printf ("expected "); mpfr_dump (y);
179 printf ("got "); mpfr_dump (x);
180 exit (1);
181 }
182
183 mpfr_clear (x);
184 mpfr_clear (y);
185 }
186
187 int
188 main (int argc, char *argv[])
189 {
190 tests_start_mpfr ();
191
192 if (argc != 1) /* teint x [prec] */
193 {
194 mpfr_t x;
195 mp_prec_t p;
196 p = (argc < 3) ? 53 : atoi (argv[2]);
197 mpfr_init2 (x, p);
198 mpfr_set_str (x, argv[1], 10, GMP_RNDN);
199 printf ("eint(");
200 mpfr_out_str (stdout, 10, 0, x, GMP_RNDN);
201 printf (")=");
202 mpfr_eint (x, x, GMP_RNDN);
203 mpfr_out_str (stdout, 10, 0, x, GMP_RNDN);
204 printf ("\n");
205 mpfr_clear (x);
206 }
207 else
208 {
209 check_specials ();
210
211 test_generic (2, 100, 100);
212 }
213
214 tests_end_mpfr ();
215 return 0;
216 }
OLDNEW
« no previous file with comments | « gcc/mpfr/tests/tdiv_ui.c ('k') | gcc/mpfr/tests/terf.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698