From 6e879c6f3361346ede165d0733a26e9145cccf69 Mon Sep 17 00:00:00 2001
From: vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>
Date: Fri, 1 Feb 2002 21:35:34 +0000
Subject: Misc bug fixes and code clean-up.

git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1678 280ebfd0-de03-0410-8827-d642c229c3f4
---
 copysign.c | 48 +++++++-----------------------------------------
 1 file changed, 7 insertions(+), 41 deletions(-)

(limited to 'copysign.c')

diff --git a/copysign.c b/copysign.c
index 1dd88dc2f..6a15ec0ce 100644
--- a/copysign.c
+++ b/copysign.c
@@ -1,6 +1,6 @@
 /* mpfr_copysign -- Produce a value with the magnitude of x and sign of y
 
-Copyright (C) 2001 Free Software Foundation.
+Copyright (C) 2001-2002 Free Software Foundation.
 
 This file is part of the MPFR Library.
 
@@ -19,7 +19,6 @@ along with the MPFR Library; see the file COPYING.LIB.  If not, write to
 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 MA 02111-1307, USA. */
 
-#include <stdio.h>
 #include "gmp.h"
 #include "gmp-impl.h"
 #include "mpfr.h"
@@ -31,46 +30,13 @@ MA 02111-1307, USA. */
  */
 
 int
-mpfr_copysign (mpfr_ptr z, mpfr_srcptr x ,mpfr_srcptr y , mp_rnd_t rnd_mode) 
+mpfr_copysign (mpfr_ptr z, mpfr_srcptr x ,mpfr_srcptr y , mp_rnd_t rnd_mode)
 {
-    
-    if (MPFR_IS_NAN(y)) 
-    {  
-      MPFR_SET_NAN(z);
-      return 1; 
-    }
-
-    if (MPFR_IS_NAN(x)) 
-    {  
-      MPFR_SET_NAN(z);
-      MPFR_SET_SAME_SIGN(z,y);
-      return 1; 
-    }
-
-    MPFR_CLEAR_NAN(z);
-
-    if (MPFR_IS_INF(x)) {  
-    
-      MPFR_SET_INF(z);
-      MPFR_SET_SAME_SIGN(z,y);
-      return 0; 
-    }
-
-    MPFR_CLEAR_INF(z);
-    
-    if (!MPFR_NOTZERO(x)) 
-    {  
-      MPFR_SET_ZERO(z);
-      MPFR_SET_SAME_SIGN(z,y);      
-      return 0; 
-    }
-    
-    /* GENERAL CASE*/
+  if (MPFR_IS_NAN(y))
     {
-      int inexact=0;
-      inexact =mpfr_set(z,x,rnd_mode);
-      MPFR_SET_SAME_SIGN(z,y);
-      return inexact; 
+      MPFR_SET_NAN(z);
+      MPFR_RET_NAN;
     }
-
+  else
+    return mpfr_set4(z, x, rnd_mode, MPFR_SIGN(y));
 }
-- 
cgit v1.2.1