xref: /netbsd-src/external/lgpl3/mpfr/dist/tests/tremquo.c (revision ba125506a622fe649968631a56eba5d42ff57863)
1 /* tremquo -- test file for mpfr_remquo, mpfr_remainder and mpfr_fmodquo.
2 
3 Copyright 2007-2023 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramba 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 3 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.LESSER.  If not, see
20 https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 
23 #include "mpfr-test.h"
24 
25 static void
bug20090227(void)26 bug20090227 (void)
27 {
28   mpfr_t x, y, r1, r2;
29 
30   mpfr_init2 (x, 118);
31   mpfr_init2 (y, 181);
32   mpfr_init2 (r1, 140);
33   mpfr_init2 (r2, 140);
34   mpfr_set_si (x, -1, MPFR_RNDN);
35   mpfr_set_str_binary (y, "1.100100100001111110110101010001000100001011010001100001000110100110001001100011001100010100010111000000011011100000111001101000100101001000000100100111000001000100010100110011111010");
36   mpfr_remainder (r1, x, y, MPFR_RNDU);
37   /* since the quotient is -1, r1 is the rounding of x+y */
38   mpfr_add (r2, x, y, MPFR_RNDU);
39   if (mpfr_cmp (r1, r2))
40     {
41       printf ("Error in mpfr_remainder (bug20090227)\n");
42       printf ("Expected ");
43       mpfr_dump (r2);
44       printf ("Got      ");
45       mpfr_dump (r1);
46       exit (1);
47     }
48   mpfr_clear (x);
49   mpfr_clear (y);
50   mpfr_clear (r1);
51   mpfr_clear (r2);
52 }
53 
54 int
main(int argc,char * argv[])55 main (int argc, char *argv[])
56 {
57   mpfr_t x, y, r;
58   long q[1];
59   int inex;
60 
61   tests_start_mpfr ();
62 
63   if (argc == 3) /* usage: tremquo x y (rnd=MPFR_RNDN implicit) */
64     {
65       mpfr_init2 (x, GMP_NUMB_BITS);
66       mpfr_init2 (y, GMP_NUMB_BITS);
67       mpfr_init2 (r, GMP_NUMB_BITS);
68       mpfr_set_str (x, argv[1], 10, MPFR_RNDN);
69       mpfr_set_str (y, argv[2], 10, MPFR_RNDN);
70       mpfr_remquo (r, q, x, y, MPFR_RNDN);
71       printf ("r=");
72       mpfr_out_str (stdout, 10, 0, r, MPFR_RNDN);
73       printf (" q=%ld\n", q[0]);
74       mpfr_clear (x);
75       mpfr_clear (y);
76       mpfr_clear (r);
77       return 0;
78     }
79 
80   bug20090227 ();
81 
82   mpfr_init (x);
83   mpfr_init (y);
84   mpfr_init (r);
85 
86   /* special values */
87   mpfr_set_nan (x);
88   mpfr_set_ui (y, 1, MPFR_RNDN);
89   mpfr_remquo (r, q, x, y, MPFR_RNDN);
90   MPFR_ASSERTN(mpfr_nan_p (r));
91   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
92   MPFR_ASSERTN(mpfr_nan_p (r));
93 
94   mpfr_set_ui (x, 1, MPFR_RNDN);
95   mpfr_set_nan (y);
96   mpfr_remquo (r, q, x, y, MPFR_RNDN);
97   MPFR_ASSERTN(mpfr_nan_p (r));
98   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
99   MPFR_ASSERTN(mpfr_nan_p (r));
100 
101   mpfr_set_inf (x, 1); /* +Inf */
102   mpfr_set_ui (y, 1, MPFR_RNDN);
103   mpfr_remquo (r, q, x, y, MPFR_RNDN);
104   MPFR_ASSERTN (mpfr_nan_p (r));
105   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
106   MPFR_ASSERTN (mpfr_nan_p (r));
107 
108   mpfr_set_inf (x, 1); /* +Inf */
109   mpfr_set_ui (y, 0, MPFR_RNDN);
110   mpfr_remquo (r, q, x, y, MPFR_RNDN);
111   MPFR_ASSERTN (mpfr_nan_p (r));
112   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
113   MPFR_ASSERTN (mpfr_nan_p (r));
114 
115   mpfr_set_inf (x, 1); /* +Inf */
116   mpfr_set_inf (y, 1);
117   mpfr_remquo (r, q, x, y, MPFR_RNDN);
118   MPFR_ASSERTN (mpfr_nan_p (r));
119   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
120   MPFR_ASSERTN (mpfr_nan_p (r));
121 
122   mpfr_set_ui (x, 0, MPFR_RNDN);
123   mpfr_set_inf (y, 1);
124   mpfr_remquo (r, q, x, y, MPFR_RNDN);
125   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r));
126   MPFR_ASSERTN (q[0] == (long) 0);
127   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
128   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r));
129   MPFR_ASSERTN (q[0] == (long) 0);
130 
131   mpfr_set_ui (x, 0, MPFR_RNDN);
132   mpfr_neg (x, x, MPFR_RNDN); /* -0 */
133   mpfr_set_inf (y, 1);
134   mpfr_remquo (r, q, x, y, MPFR_RNDN);
135   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r));
136   MPFR_ASSERTN (q[0] == (long) 0);
137   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
138   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r));
139   MPFR_ASSERTN (q[0] == (long) 0);
140 
141   mpfr_set_ui (x, 17, MPFR_RNDN);
142   mpfr_set_inf (y, 1);
143   mpfr_remquo (r, q, x, y, MPFR_RNDN);
144   MPFR_ASSERTN (mpfr_cmp (r, x) == 0);
145   MPFR_ASSERTN (q[0] == (long) 0);
146   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
147   MPFR_ASSERTN (mpfr_cmp (r, x) == 0);
148   MPFR_ASSERTN (q[0] == (long) 0);
149 
150   mpfr_set_ui (x, 17, MPFR_RNDN);
151   mpfr_set_ui (y, 0, MPFR_RNDN);
152   mpfr_remquo (r, q, x, y, MPFR_RNDN);
153   MPFR_ASSERTN (mpfr_nan_p (r));
154   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
155   MPFR_ASSERTN (mpfr_nan_p (r));
156 
157   mpfr_set_ui (x, 0, MPFR_RNDN);
158   mpfr_set_ui (y, 17, MPFR_RNDN);
159   mpfr_remquo (r, q, x, y, MPFR_RNDN);
160   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r));
161   MPFR_ASSERTN (q[0] == (long) 0);
162   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
163   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_POS (r));
164   MPFR_ASSERTN (q[0] == (long) 0);
165 
166   mpfr_set_ui (x, 0, MPFR_RNDN);
167   mpfr_neg (x, x, MPFR_RNDN);
168   mpfr_set_ui (y, 17, MPFR_RNDN);
169   mpfr_remquo (r, q, x, y, MPFR_RNDN);
170   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r));
171   MPFR_ASSERTN (q[0] == (long) 0);
172   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
173   MPFR_ASSERTN (mpfr_cmp_ui (r, 0) == 0 && MPFR_IS_NEG (r));
174   MPFR_ASSERTN (q[0] == (long) 0);
175 
176   mpfr_set_prec (x, 53);
177   mpfr_set_prec (y, 53);
178 
179   /* check four possible sign combinations for 42/17 */
180   mpfr_set_ui (x, 42, MPFR_RNDN);
181   mpfr_set_ui (y, 17, MPFR_RNDN);
182   mpfr_remquo (r, q, x, y, MPFR_RNDN);
183   MPFR_ASSERTN (mpfr_cmp_ui (r, 8) == 0);
184   MPFR_ASSERTN (q[0] == (long) 2);
185   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
186   MPFR_ASSERTN (mpfr_cmp_ui (r, 8) == 0);
187   MPFR_ASSERTN (q[0] == (long) 2);
188 
189   mpfr_set_si (x, -42, MPFR_RNDN);
190   mpfr_set_ui (y, 17, MPFR_RNDN);
191   mpfr_remquo (r, q, x, y, MPFR_RNDN);
192   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
193   MPFR_ASSERTN (q[0] == (long) -2);
194   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
195   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
196   MPFR_ASSERTN (q[0] == (long) -2);
197 
198   mpfr_set_si (x, -42, MPFR_RNDN);
199   mpfr_set_si (y, -17, MPFR_RNDN);
200   mpfr_remquo (r, q, x, y, MPFR_RNDN);
201   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
202   MPFR_ASSERTN (q[0] == (long) 2);
203   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
204   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
205   MPFR_ASSERTN (q[0] == (long) 2);
206 
207   mpfr_set_ui (x, 42, MPFR_RNDN);
208   mpfr_set_si (y, -17, MPFR_RNDN);
209   mpfr_remquo (r, q, x, y, MPFR_RNDN);
210   MPFR_ASSERTN (mpfr_cmp_ui (r, 8) == 0);
211   MPFR_ASSERTN (q[0] == (long) -2);
212   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
213   MPFR_ASSERTN (mpfr_cmp_ui (r, 8) == 0);
214   MPFR_ASSERTN (q[0] == (long) -2);
215 
216   /* same tests for 43/17, rounded to 3 to nearest, and to 2 to zero */
217   mpfr_set_ui (x, 43, MPFR_RNDN);
218   mpfr_set_ui (y, 17, MPFR_RNDN);
219   mpfr_remquo (r, q, x, y, MPFR_RNDN);
220   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
221   MPFR_ASSERTN (q[0] == (long) 3);
222   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
223   MPFR_ASSERTN (mpfr_cmp_ui (r, 9) == 0);
224   MPFR_ASSERTN (q[0] == (long) 2);
225 
226   mpfr_set_si (x, -43, MPFR_RNDN);
227   mpfr_set_ui (y, 17, MPFR_RNDN);
228   mpfr_remquo (r, q, x, y, MPFR_RNDN);
229   MPFR_ASSERTN (mpfr_cmp_si (r, 8) == 0);
230   MPFR_ASSERTN (q[0] == (long) -3);
231   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
232   MPFR_ASSERTN (mpfr_cmp_si (r, -9) == 0);
233   MPFR_ASSERTN (q[0] == (long) -2);
234 
235   mpfr_set_si (x, -43, MPFR_RNDN);
236   mpfr_set_si (y, -17, MPFR_RNDN);
237   mpfr_remquo (r, q, x, y, MPFR_RNDN);
238   MPFR_ASSERTN (mpfr_cmp_si (r, 8) == 0);
239   MPFR_ASSERTN (q[0] == (long) 3);
240   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
241   MPFR_ASSERTN (mpfr_cmp_si (r, -9) == 0);
242   MPFR_ASSERTN (q[0] == (long) 2);
243 
244   mpfr_set_ui (x, 43, MPFR_RNDN);
245   mpfr_set_si (y, -17, MPFR_RNDN);
246   mpfr_remquo (r, q, x, y, MPFR_RNDN);
247   MPFR_ASSERTN (mpfr_cmp_si (r, -8) == 0);
248   MPFR_ASSERTN (q[0] == (long) -3);
249   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
250   MPFR_ASSERTN (mpfr_cmp_ui (r, 9) == 0);
251   MPFR_ASSERTN (q[0] == (long) -2);
252 
253   /* other tests */
254   mpfr_set_prec (x, 100);
255   mpfr_set_prec (y, 50);
256   mpfr_set_ui (x, 42, MPFR_RNDN);
257   mpfr_nextabove (x); /* 42 + 2^(-94) */
258   mpfr_set_ui (y, 21, MPFR_RNDN);
259   mpfr_remquo (r, q, x, y, MPFR_RNDN);
260   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -94) == 0);
261   MPFR_ASSERTN (q[0] == (long) 2);
262   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
263   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -94) == 0);
264   MPFR_ASSERTN (q[0] == (long) 2);
265 
266   mpfr_set_prec (x, 50);
267   mpfr_set_prec (y, 100);
268   mpfr_set_ui (x, 42, MPFR_RNDN);
269   mpfr_nextabove (x); /* 42 + 2^(-44) */
270   mpfr_set_ui (y, 21, MPFR_RNDN);
271   mpfr_remquo (r, q, x, y, MPFR_RNDN);
272   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -44) == 0);
273   MPFR_ASSERTN (q[0] == (long) 2);
274   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
275   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -44) == 0);
276   MPFR_ASSERTN (q[0] == (long) 2);
277 
278   mpfr_set_prec (x, 100);
279   mpfr_set_prec (y, 50);
280   mpfr_set_ui (x, 42, MPFR_RNDN);
281   mpfr_set_ui (y, 21, MPFR_RNDN);
282   mpfr_nextabove (y); /* 21 + 2^(-45) */
283   mpfr_remquo (r, q, x, y, MPFR_RNDN);
284   /* r should be 42 - 2*(21 + 2^(-45)) = -2^(-44) */
285   MPFR_ASSERTN (mpfr_cmp_si_2exp (r, -1, -44) == 0);
286   MPFR_ASSERTN (q[0] == (long) 2);
287   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
288   /* r should be 42 - (21 + 2^(-45) = 21 - 2^(-45) */
289   mpfr_sub_ui (r, r, 21, MPFR_RNDN);
290   MPFR_ASSERTN (mpfr_cmp_si_2exp (r, -1, -45) == 0);
291   MPFR_ASSERTN (q[0] == (long) 1);
292 
293   mpfr_set_prec (x, 50);
294   mpfr_set_prec (y, 100);
295   mpfr_set_ui (x, 42, MPFR_RNDN);
296   mpfr_set_ui (y, 21, MPFR_RNDN);
297   mpfr_nextabove (y); /* 21 + 2^(-95) */
298   mpfr_remquo (r, q, x, y, MPFR_RNDN);
299   /* r should be 42 - 2*(21 + 2^(-95)) = -2^(-94) */
300   MPFR_ASSERTN (mpfr_cmp_si_2exp (r, -1, -94) == 0);
301   MPFR_ASSERTN (q[0] == (long) 2);
302   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
303   /* r should be 42 - (21 + 2^(-95) = 21 - 2^(-94), which rounded to 53 bits
304      should give 21 */
305   MPFR_ASSERTN (mpfr_cmp_ui (r, 21) == 0);
306   MPFR_ASSERTN (q[0] == (long) 1);
307 
308   /* exercise large quotient */
309   mpfr_set_ui_2exp (x, 1, 65, MPFR_RNDN);
310   mpfr_set_ui (y, 1, MPFR_RNDN);
311   /* quotient is 2^65 */
312   mpfr_remquo (r, q, x, y, MPFR_RNDN);
313   MPFR_ASSERTN (mpfr_cmp_si (r, 0) == 0);
314   MPFR_ASSERTN (q[0] % 1073741824L == 0L);
315   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
316   MPFR_ASSERTN (mpfr_cmp_si (r, 0) == 0);
317   MPFR_ASSERTN (q[0] % 1073741824L == 0L);
318 
319   /* another large quotient */
320   mpfr_set_prec (x, 65);
321   mpfr_set_prec (y, 65);
322   mpfr_const_pi (x, MPFR_RNDN);
323   mpfr_mul_2ui (x, x, 63, MPFR_RNDN);
324   mpfr_const_log2 (y, MPFR_RNDN);
325   mpfr_set_prec (r, 10);
326   mpfr_remquo (r, q, x, y, MPFR_RNDN);
327   /* q should be 41803643793084085130, r should be 605/2048 */
328   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 605, -11) == 0);
329   MPFR_ASSERTN ((q[0] > 0) && ((q[0] % 1073741824L) == 733836170L));
330   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
331   /* q should be 41803643793084085130, r should be 605/2048 */
332   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 605, -11) == 0);
333   MPFR_ASSERTN ((q[0] > 0) && ((q[0] % 1073741824L) == 733836170L));
334 
335   /* check cases where quotient is 1.5 +/- eps */
336   mpfr_set_prec (x, 65);
337   mpfr_set_prec (y, 65);
338   mpfr_set_prec (r, 63);
339   mpfr_set_ui (x, 3, MPFR_RNDN);
340   mpfr_set_ui (y, 2, MPFR_RNDN);
341   mpfr_remquo (r, q, x, y, MPFR_RNDN);
342   /* x/y = 1.5, quotient should be 2 (even rule), remainder should be -1 */
343   MPFR_ASSERTN (mpfr_cmp_si (r, -1) == 0);
344   MPFR_ASSERTN (q[0] == 2L);
345   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
346   /* x/y = 1.5, quotient should be 1, remainder should be 1 */
347   MPFR_ASSERTN (mpfr_cmp_si (r, 1) == 0);
348   MPFR_ASSERTN (q[0] == 1L);
349 
350   mpfr_set_ui (x, 3, MPFR_RNDN);
351   mpfr_nextabove (x); /* 3 + 2^(-63) */
352   mpfr_set_ui (y, 2, MPFR_RNDN);
353   mpfr_remquo (r, q, x, y, MPFR_RNDN);
354   /* x/y = 1.5 + 2^(-64), quo should be 2, r should be -1 + 2^(-63) */
355   MPFR_ASSERTN (mpfr_add_ui (r, r, 1, MPFR_RNDN) == 0);
356   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -63) == 0);
357   MPFR_ASSERTN (q[0] == 2L);
358   mpfr_set_prec (r, 64);
359   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
360   /* x/y = 1.5 + 2^(-64), quo should be 1, r should be 1 + 2^(-63) */
361   MPFR_ASSERTN (mpfr_sub_ui (r, r, 1, MPFR_RNDN) == 0);
362   MPFR_ASSERTN (mpfr_cmp_ui_2exp (r, 1, -63) == 0);
363   MPFR_ASSERTN (q[0] == 1L);
364 
365   mpfr_set_prec (r, 63);
366   mpfr_set_ui (x, 3, MPFR_RNDN);
367   mpfr_set_ui (y, 2, MPFR_RNDN);
368   mpfr_nextabove (y); /* 2 + 2^(-63) */
369   mpfr_remquo (r, q, x, y, MPFR_RNDN);
370   /* x/y = 1.5 - eps, quo should be 1, r should be 1 - 2^(-63) */
371   MPFR_ASSERTN (mpfr_sub_ui (r, r, 1, MPFR_RNDN) == 0);
372   MPFR_ASSERTN (mpfr_cmp_si_2exp (r, -1, -63) == 0);
373   MPFR_ASSERTN (q[0] == 1L);
374   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
375   /* x/y = 1.5 - eps, quo should be 1, r should be 1 - 2^(-63) */
376   MPFR_ASSERTN (mpfr_sub_ui (r, r, 1, MPFR_RNDN) == 0);
377   MPFR_ASSERTN (mpfr_cmp_si_2exp (r, -1, -63) == 0);
378   MPFR_ASSERTN (q[0] == 1L);
379 
380   /* bug founds by Kaveh Ghazi, 3 May 2007 */
381   mpfr_set_ui (x, 2, MPFR_RNDN);
382   mpfr_set_ui (y, 3, MPFR_RNDN);
383   /* quotient rounded to nearest is 1, thus remainder is -1 */
384   mpfr_remainder (r, x, y, MPFR_RNDN);
385   MPFR_ASSERTN (mpfr_cmp_si (r, -1) == 0);
386 
387   mpfr_set_si (x, -1, MPFR_RNDN);
388   mpfr_set_ui (y, 1, MPFR_RNDN);
389   mpfr_remainder (r, x, y, MPFR_RNDN);
390   MPFR_ASSERTN (mpfr_cmp_si (r, 0) == 0 && MPFR_IS_NEG (r));
391 
392   /* check argument reuse */
393   mpfr_set_si (x, -1, MPFR_RNDN);
394   mpfr_set_ui (y, 1, MPFR_RNDN);
395   mpfr_remainder (x, x, y, MPFR_RNDN);
396   MPFR_ASSERTN (mpfr_cmp_si (x, 0) == 0 && MPFR_IS_NEG (x));
397 
398   mpfr_set_ui_2exp (x, 1, mpfr_get_emax () - 1, MPFR_RNDN);
399   mpfr_set_ui_2exp (y, 1, mpfr_get_emin (), MPFR_RNDN);
400   mpfr_remquo (r, q, x, y, MPFR_RNDN);
401   MPFR_ASSERTN (mpfr_zero_p (r) && MPFR_IS_POS (r));
402   MPFR_ASSERTN (q[0] == 0);
403   mpfr_fmodquo (r, q, x, y, MPFR_RNDN);
404   MPFR_ASSERTN (mpfr_zero_p (r) && MPFR_IS_POS (r));
405   MPFR_ASSERTN (q[0] == 0);
406 
407   mpfr_set_prec (x, 380);
408   mpfr_set_prec (y, 385);
409   mpfr_set_str_binary (x, "0.11011010010110011101011000100100101100101011010001011100110001100101111001010100001011111110111100101110101010110011010101000100000100011101101100001011101110100111101111111010001001000010000110010110011100111000001110111010000100101001010111100100010001101001110100011110010000000001110001111001101100111011001000110110011100100011111110010100011001000001001011010111010000000000E-2");
410   mpfr_set_str_binary (y, "0.1100011000011101011010001100010111001110110111001101010010111100111100011010010011011101111101111001010111111110001001100001111101001000000010100101111001001110010110000111001000101010111001001000100101011111000010100110001111000110011011010101111101100110010101011010011101100001011101001000101111110110110110000001001101110111110110111110111111001001011110001110011111100000000000000E-1");
411   mpfr_set_prec (r, 2);
412   inex = mpfr_remainder (r, x, y, MPFR_RNDA);
413   MPFR_ASSERTN(mpfr_cmp_si_2exp (r, -3, -4) == 0);
414   MPFR_ASSERTN(inex < 0);
415 
416   mpfr_clear (x);
417   mpfr_clear (y);
418   mpfr_clear (r);
419 
420   tests_end_mpfr ();
421 
422   return 0;
423 }
424