From fb2c034b3abf14faa4be065831f1a576cd559d69 Mon Sep 17 00:00:00 2001 From: Marco Bodrato Date: Fri, 11 Sep 2015 07:59:12 +0200 Subject: mpf_cmp_z, with test. --- mpf/Makefile.am | 2 +- mpf/cmp_z.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 mpf/cmp_z.c (limited to 'mpf') diff --git a/mpf/Makefile.am b/mpf/Makefile.am index ceea072cc..ff7e48faf 100644 --- a/mpf/Makefile.am +++ b/mpf/Makefile.am @@ -37,7 +37,7 @@ libmpf_la_SOURCES = \ set_q.c iset.c iset_ui.c iset_si.c iset_str.c iset_d.c clear.c clears.c \ get_str.c dump.c size.c eq.c reldiff.c sqrt.c random2.c inp_str.c out_str.c \ add.c add_ui.c sub.c sub_ui.c ui_sub.c mul.c mul_ui.c div.c div_ui.c \ - cmp.c cmp_d.c cmp_si.c cmp_ui.c mul_2exp.c div_2exp.c abs.c neg.c get_d.c \ + cmp.c cmp_d.c cmp_z.c cmp_si.c cmp_ui.c mul_2exp.c div_2exp.c abs.c neg.c get_d.c \ get_d_2exp.c set_dfl_prec.c set_prc.c set_prc_raw.c get_dfl_prec.c get_prc.c \ ui_div.c sqrt_ui.c \ pow_ui.c urandomb.c swap.c get_si.c get_ui.c int_p.c \ diff --git a/mpf/cmp_z.c b/mpf/cmp_z.c new file mode 100644 index 000000000..e9c1559d6 --- /dev/null +++ b/mpf/cmp_z.c @@ -0,0 +1,46 @@ +/* mpf_cmp_z -- Compare a float with an integer. + +Copyright 2015 Free Software Foundation, Inc. + +This file is part of the GNU MP Library. + +The GNU MP Library is free software; you can redistribute it and/or modify +it under the terms of either: + + * the GNU Lesser General Public License as published by the Free + Software Foundation; either version 3 of the License, or (at your + option) any later version. + +or + + * the GNU General Public License as published by the Free Software + Foundation; either version 2 of the License, or (at your option) any + later version. + +or both in parallel, as here. + +The GNU MP Library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received copies of the GNU General Public License and the +GNU Lesser General Public License along with the GNU MP Library. If not, +see https://www.gnu.org/licenses/. */ + +#include "gmp.h" +#include "gmp-impl.h" + +int +mpf_cmp_z (mpf_srcptr u, mpz_srcptr v) __GMP_NOTHROW +{ + mpf_t vf; + mp_size_t size; + + SIZ (vf) = size = SIZ (v); + EXP (vf) = size = ABS (size); + /* PREC (vf) = size; */ + PTR (vf) = PTR (v); + + return mpf_cmp (u, vf); +} -- cgit v1.2.1