summaryrefslogtreecommitdiff
path: root/sub1sp.c
diff options
context:
space:
mode:
authorpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-06-08 09:13:41 +0000
committerpelissip <pelissip@280ebfd0-de03-0410-8827-d642c229c3f4>2005-06-08 09:13:41 +0000
commit231f4ba0724d1be2aedd788c851f0da24dda74cc (patch)
tree558acff926ae373e2f1432285613479ca2faefd4 /sub1sp.c
parent0672e8c46a8eb317bfa2aed7f3f26da6926830d7 (diff)
downloadmpfr-231f4ba0724d1be2aedd788c851f0da24dda74cc.tar.gz
Clean up code.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@3629 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'sub1sp.c')
-rw-r--r--sub1sp.c46
1 files changed, 25 insertions, 21 deletions
diff --git a/sub1sp.c b/sub1sp.c
index 236c3cdf7..c219f8370 100644
--- a/sub1sp.c
+++ b/sub1sp.c
@@ -21,18 +21,13 @@ along with the MPFR Library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Place, Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include <stdio.h>
+#if defined(DEBUG) || defined(WANT_ASSERT)
+# include <stdio.h>
+#endif
#define MPFR_NEED_LONGLONG_H
#include "mpfr-impl.h"
-/*
- compute sgn(b)*(|b| - |c|) if |b|>|c| else -sgn(b)*(|c| -|b|)
- Returns 0 iff result is exact,
- a negative value when the result is less than the exact value,
- a positive value otherwise.
-*/
-
#ifdef DEBUG
# undef DEBUG
# define DEBUG(x) (x)
@@ -50,40 +45,49 @@ int mpfr_sub1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode)
mpfr_t tmpa, tmpb, tmpc;
int inexact, inexact2;
- mpfr_init2(tmpa, mpfr_get_prec(a));
- mpfr_init2(tmpb, mpfr_get_prec(b));
- mpfr_init2(tmpc, mpfr_get_prec(c));
- MPFR_ASSERTN (mpfr_set(tmpb, b, GMP_RNDN) == 0);
- MPFR_ASSERTN (mpfr_set(tmpc, c, GMP_RNDN) == 0);
+ mpfr_init2 (tmpa, MPFR_PREC (a));
+ mpfr_init2 (tmpb, MPFR_PREC (b));
+ mpfr_init2 (tmpc, MPFR_PREC (c));
+ MPFR_ASSERTN (mpfr_set (tmpb, b, GMP_RNDN) == 0);
+ MPFR_ASSERTN (mpfr_set (tmpc, c, GMP_RNDN) == 0);
inexact2 = mpfr_sub1 (tmpa, tmpb, tmpc, rnd_mode);
inexact = mpfr_sub1sp2(a, b, c, rnd_mode);
- if (mpfr_cmp(tmpa, a) || inexact!=inexact2)
+ if (mpfr_cmp (tmpa, a) || inexact != inexact2)
{
printf("sub1 & sub1sp return different values for %s\n"
"Prec_a= %lu Prec_b= %lu Prec_c= %lu\nB=",
mpfr_print_rnd_mode(rnd_mode),
- mpfr_get_prec(a), mpfr_get_prec(b), mpfr_get_prec(c));
- mpfr_print_binary(tmpb);
+ MPFR_PREC (a), MPFR_PREC (b), MPFR_PREC (c));
+ mpfr_print_binary (tmpb);
printf("\nC=");
- mpfr_print_binary(tmpc);
+ mpfr_print_binary (tmpc);
printf("\nSub1 : ");
- mpfr_print_binary(tmpa);
+ mpfr_print_binary (tmpa);
printf("\nSub1sp: ");
- mpfr_print_binary(a);
+ mpfr_print_binary (a);
printf("\nInexact sp = %d | Inexact = %d\n", inexact, inexact2);
- MPFR_ASSERTN(0);
+ MPFR_ASSERTN (0);
}
- mpfr_clears(tmpa, tmpb, tmpc, NULL);
+ mpfr_clears (tmpa, tmpb, tmpc, NULL);
return inexact;
}
# define mpfr_sub1sp mpfr_sub1sp2
# endif
#endif
+
+
/* Rounding Sub */
+/*
+ compute sgn(b)*(|b| - |c|) if |b|>|c| else -sgn(b)*(|c| -|b|)
+ Returns 0 iff result is exact,
+ a negative value when the result is less than the exact value,
+ a positive value otherwise.
+*/
+
/* A0...Ap-1
* Cp Cp+1 ....
* <- C'p+1 ->