summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-03 08:01:45 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2003-10-03 08:01:45 +0000
commit770d47959c21ec97a204fad88ba033ed03a699a8 (patch)
treea32963daaab6d9ad977d8b4d87f2c4d3cc988e2b
parent8b165f4d145f302ac6292a3b7644c3cd1424f7f1 (diff)
downloadmpfr-770d47959c21ec97a204fad88ba033ed03a699a8.tar.gz
Infinities are now accepted in mpfr_cmpabs. Updated its definition
in the source (no longer sign(abs(b) - abs(c))). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2469 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--cmp_abs.c21
-rw-r--r--mpfr.texi5
2 files changed, 15 insertions, 11 deletions
diff --git a/cmp_abs.c b/cmp_abs.c
index 47d1bc2e4..084e6dba2 100644
--- a/cmp_abs.c
+++ b/cmp_abs.c
@@ -24,8 +24,8 @@ MA 02111-1307, USA. */
#include "mpfr.h"
#include "mpfr-impl.h"
-/* returns sign(abs(b) - abs(c))
- b and c must be real numbers */
+/* 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. */
int
mpfr_cmpabs (mpfr_srcptr b, mpfr_srcptr c)
@@ -34,13 +34,18 @@ mpfr_cmpabs (mpfr_srcptr b, mpfr_srcptr c)
mp_size_t bn, cn;
mp_limb_t *bp, *cp;
- MPFR_ASSERTN(MPFR_IS_FP(b));
- MPFR_ASSERTN(MPFR_IS_FP(c));
+ MPFR_ASSERTN (! MPFR_IS_NAN (b));
+ MPFR_ASSERTN (! MPFR_IS_NAN (c));
- if (MPFR_IS_ZERO(b))
- return MPFR_IS_ZERO(c) ? 0 : -1;
- if (MPFR_IS_ZERO(c))
- return 1;
+ if (MPFR_IS_INF (b))
+ return ! MPFR_IS_INF (c);
+ if (MPFR_IS_INF (c))
+ return -1;
+
+ if (MPFR_IS_ZERO (c))
+ return ! MPFR_IS_ZERO (b);
+ if (MPFR_IS_ZERO (b))
+ return -1;
be = MPFR_GET_EXP (b);
ce = MPFR_GET_EXP (c);
diff --git a/mpfr.texi b/mpfr.texi
index 19b6e7318..d18aba564 100644
--- a/mpfr.texi
+++ b/mpfr.texi
@@ -1091,7 +1091,7 @@ Compare @var{op1} and @var{op2}. Return a positive value if @math{@var{op1} >
@math{@var{op1} < @var{op2}}.
Both @var{op1} and @var{op2} are considered to their full own precision,
which may differ.
-It is not allowed that one of the operands is NaN (Not-a-Number).
+If one of the operands is NaN (Not-a-Number), the behavior is undefined.
@end deftypefun
@deftypefun int mpfr_cmp_ui_2exp (mpfr_t @var{op1}, unsigned long int @var{op2}, mp_exp_t @var{e})
@@ -1104,8 +1104,7 @@ the power @var{e}}. Similar as above.
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}|}.
-It is not allowed that one of the operands is NaN (Not-a-Number) or an
-infinity.
+If one of the operands is NaN (Not-a-Number), the behavior is undefined.
@end deftypefun
@deftypefun int mpfr_eq (mpfr_t @var{op1}, mpfr_t @var{op2}, unsigned long int @var{op3})