cmp_str.c revision 1.1 1 1.1 mrg /* mpfr_cmp_str -- compare a floating-point number with a string.
2 1.1 mrg
3 1.1 mrg Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
4 1.1 mrg Contributed by the Arenaire and Cacao projects, INRIA.
5 1.1 mrg
6 1.1 mrg This file is part of the GNU MPFR Library.
7 1.1 mrg
8 1.1 mrg The GNU MPFR Library is free software; you can redistribute it and/or modify
9 1.1 mrg it under the terms of the GNU Lesser General Public License as published by
10 1.1 mrg the Free Software Foundation; either version 3 of the License, or (at your
11 1.1 mrg option) any later version.
12 1.1 mrg
13 1.1 mrg The GNU MPFR Library is distributed in the hope that it will be useful, but
14 1.1 mrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 1.1 mrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16 1.1 mrg License for more details.
17 1.1 mrg
18 1.1 mrg You should have received a copy of the GNU Lesser General Public License
19 1.1 mrg along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
20 1.1 mrg http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
21 1.1 mrg 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
22 1.1 mrg
23 1.1 mrg #include "mpfr-test.h"
24 1.1 mrg
25 1.1 mrg int
26 1.1 mrg mpfr_cmp_str (mpfr_srcptr x, const char *s, int base, mpfr_rnd_t rnd)
27 1.1 mrg {
28 1.1 mrg mpfr_t y;
29 1.1 mrg int res;
30 1.1 mrg
31 1.1 mrg MPFR_ASSERTN (!MPFR_IS_NAN (x));
32 1.1 mrg mpfr_init2 (y, MPFR_PREC(x));
33 1.1 mrg mpfr_set_str (y, s, base, rnd);
34 1.1 mrg res = mpfr_cmp (x,y);
35 1.1 mrg mpfr_clear (y);
36 1.1 mrg return res;
37 1.1 mrg }
38