[Mpfi-commits] r310 - trunk/mpfi/src

ptheveny at users.gforge.inria.fr ptheveny at users.gforge.inria.fr
Mar 22 Juin 13:41:21 CEST 2010


Author: ptheveny
Date: 2010-06-22 13:41:21 +0200 (Tue, 22 Jun 2010)
New Revision: 310

Modified:
   trunk/mpfi/src/mag.c
Log:
Simplify mpfi_mag code and change GMP_RNDx to MPFI_RNDx.

Modified: trunk/mpfi/src/mag.c
===================================================================
--- trunk/mpfi/src/mag.c	2010-06-22 11:39:02 UTC (rev 309)
+++ trunk/mpfi/src/mag.c	2010-06-22 11:41:21 UTC (rev 310)
@@ -33,25 +33,25 @@
 {
   int inexact;
 
-  if (mpfi_is_nonneg_default (x))
-    inexact = mpfr_set (m, &(x->right), GMP_RNDU);
-  else if (mpfi_is_nonpos_default (x))
-    inexact = mpfr_neg (m, &(x->left), GMP_RNDU);
+  if (MPFI_NAN_P (x)) {
+    mpfr_set_nan (m);
+    MPFR_RET_NAN;
+  }
+
+  if (mpfi_is_nonneg_default (x)) {
+    inexact = mpfr_set (m, &(x->right), MPFI_RNDU);
+    if (mpfr_zero_p (m) && mpfr_signbit (m))
+      /* fix sign of zero */
+      mpfr_neg (m, m, MPFI_RNDU);
+  }
+  else if (mpfi_is_nonpos_default (x)) {
+    inexact = mpfr_neg (m, &(x->left), MPFI_RNDU);
+  }
   else { /* x contains 0 */
-    inexact = mpfr_neg (m, &(x->left), GMP_RNDU);
-    if (mpfr_nan_p (m)) {
-      MPFR_RET_NAN;
-    }
-    else {
-      if (mpfr_cmp (m, &(x->right)) < 0)
-        inexact = mpfr_set (m, &(x->right), GMP_RNDU);
-      if (mpfr_nan_p (m))
-        MPFR_RET_NAN;
-    }
+    inexact = mpfr_neg (m, &(x->left), MPFI_RNDU);
+    if (mpfr_cmp (m, &(x->right)) < 0)
+      inexact = mpfr_set (m, &(x->right), MPFI_RNDU);
   }
-  if (mpfr_signbit (m))
-    /* fix sign of zero */
-    mpfr_neg (m, m, MPFI_RNDU);
 
   return inexact;
 }




More information about the Mpfi-commits mailing list