diff options
author | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-02-12 12:51:55 +0000 |
---|---|---|
committer | zimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-02-12 12:51:55 +0000 |
commit | c23acd1d9d7068e5d29aac7f733b53596c0e14e6 (patch) | |
tree | d28b756f0b7d2cbc041806187fecd6f232a0c18a | |
parent | 07972abaf0b1a5b921788382d85327d6ef18cfe3 (diff) | |
download | mpfr-c23acd1d9d7068e5d29aac7f733b53596c0e14e6.tar.gz |
added new function mpfr_cmpabs_ui
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13708 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | doc/mpfr.texi | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/cmpabs.c | 2 | ||||
-rw-r--r-- | src/cmpabs_ui.c | 35 |
4 files changed, 38 insertions, 2 deletions
diff --git a/doc/mpfr.texi b/doc/mpfr.texi index 216b668b3..247bdccd1 100644 --- a/doc/mpfr.texi +++ b/doc/mpfr.texi @@ -2051,6 +2051,7 @@ the power @var{e}}. Similar as above. @end deftypefun @deftypefun int mpfr_cmpabs (mpfr_t @var{op1}, mpfr_t @var{op2}) +@deftypefunx int mpfr_cmpabs (mpfr_t @var{op1}, unsigned long @var{op2}) Compare @math{|@var{op1}|} and @math{|@var{op2}|}. Return a positive value if @math{|@var{op1}| > |@var{op2}|}, zero if @math{|@var{op1}| = |@var{op2}|}, and a negative value if @math{|@var{op1}| < |@var{op2}|}. diff --git a/src/Makefile.am b/src/Makefile.am index 772e24399..0a2e9ce17 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -67,7 +67,7 @@ grandom.c fpif.c set_float128.c get_float128.c rndna.c nrandom.c \ random_deviate.h random_deviate.c erandom.c mpfr-mini-gmp.c \ mpfr-mini-gmp.h fmma.c log_ui.c gamma_inc.c ubf.c invert_limb.h \ invsqrt_limb.h beta.c odd_p.c get_q.c pool.c total_order.c set_d128.c \ -get_d128.c nbits_ulong.c +get_d128.c nbits_ulong.c cmpabs_ui.c nodist_libmpfr_la_SOURCES = $(BUILT_SOURCES) diff --git a/src/cmpabs.c b/src/cmpabs.c index d5b75bb60..90642e78d 100644 --- a/src/cmpabs.c +++ b/src/cmpabs.c @@ -23,7 +23,7 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #include "mpfr-impl.h" /* Return a positive value if abs(b) > abs(c), 0 if abs(b) = abs(c), and - a negative value if abs(b) < abs(c). Neither b nor c may be NaN. */ + a negative value if abs(b) < abs(c). */ int mpfr_cmpabs (mpfr_srcptr b, mpfr_srcptr c) diff --git a/src/cmpabs_ui.c b/src/cmpabs_ui.c new file mode 100644 index 000000000..8ca8f3aac --- /dev/null +++ b/src/cmpabs_ui.c @@ -0,0 +1,35 @@ +/* mpfr_cmpabs_ui -- compare the absolute value of FP to an unsigned long + +Copyright 2020 Free Software Foundation, Inc. +Contributed by the AriC and Caramba projects, INRIA. + +This file is part of the GNU MPFR Library. + +The GNU MPFR Library is free software; you can redistribute it and/or modify +it under the terms of 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. + +The GNU MPFR 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 Lesser General Public +License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see +https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#include "mpfr-impl.h" + +/* Return a positive value if abs(b) > c, 0 if abs(b) = c, and + a negative value if abs(b) < c. */ + +int +mpfr_cmpabs_ui (mpfr_srcptr b, unsigned long c) +{ + mpfr_t absb; + + MPFR_TMP_INIT_ABS (absb, b); + return mpfr_cmp_ui (absb, c); +} |