1 /* Test file for mpfr_inp_str.
3 Copyright 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
4 Contributed by the AriC and Caramel projects, INRIA.
6 This file is part of the GNU MPFR Library.
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.
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.
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 http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
26 #include "mpfr-test.h"
29 main (int argc, char *argv[])
40 mpfr_set_prec (x, 15);
41 f = src_fopen ("inp_str.data", "r");
44 printf ("Error, can't open inp_str.data\n");
47 i = mpfr_inp_str (x, f, 10, MPFR_RNDN);
48 if (i == 0 || mpfr_cmp_ui (x, 31415))
50 printf ("Error in reading 1st line from file inp_str.data (%d)\n", i);
55 i = mpfr_inp_str (x, f, 10, MPFR_RNDN);
56 if ((i == 0) || mpfr_cmp_ui (x, 31416))
58 printf ("Error in reading 2nd line from file inp_str.data (%d)\n", i);
63 i = mpfr_inp_str (x, f, 10, MPFR_RNDN);
66 printf ("Error in reading 3rd line from file inp_str.data (%d)\n", i);
71 mpfr_set_prec (x, 53);
72 mpfr_set_prec (y, 53);
73 mpfr_set_str (y, "1.0010010100001110100101001110011010111011100001110010e226",
75 for (i = 2; i < 63; i++)
78 if (mpfr_inp_str (x, f, i, MPFR_RNDN) == 0 || !mpfr_equal_p (x, y))
80 printf ("Error in reading %dth line from file inp_str.data\n", i+2);
84 mpfr_set_ui (x, 0, MPFR_RNDN);