Home | History | Annotate | Line # | Download | only in tests
      1      1.1  mrg /* mpfr_cmp_str -- compare a floating-point number with a string.
      2      1.1  mrg 
      3  1.1.1.6  mrg Copyright 2004-2023 Free Software Foundation, Inc.
      4  1.1.1.3  mrg Contributed by the AriC and Caramba 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.1.5  mrg https://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.1.6  mrg   MPFR_ASSERTN (!MPFR_IS_NAN (y));
     35  1.1.1.6  mrg   res = mpfr_cmp (x, y);
     36      1.1  mrg   mpfr_clear (y);
     37      1.1  mrg   return res;
     38      1.1  mrg }
     39