summaryrefslogtreecommitdiffstats
path: root/libm/src/s_copysign.c
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commita27d2baa0c1a2ec70f47ea9199b1dd6762c8a349 (patch)
treedefd1cc07d16ad2f3b21154114e092d11c94c5bb /libm/src/s_copysign.c
downloadbionic-1d77faaaade70555d4b6667b02e7c07b05477401.zip
bionic-1d77faaaade70555d4b6667b02e7c07b05477401.tar.gz
bionic-1d77faaaade70555d4b6667b02e7c07b05477401.tar.bz2
Initial Contributionandroid-1.0
Diffstat (limited to 'libm/src/s_copysign.c')
-rw-r--r--libm/src/s_copysign.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/libm/src/s_copysign.c b/libm/src/s_copysign.c
new file mode 100644
index 0000000..f37be0d
--- /dev/null
+++ b/libm/src/s_copysign.c
@@ -0,0 +1,34 @@
+/* @(#)s_copysign.c 5.1 93/09/24 */
+/*
+ * ====================================================
+ * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+ *
+ * Developed at SunPro, a Sun Microsystems, Inc. business.
+ * Permission to use, copy, modify, and distribute this
+ * software is freely granted, provided that this notice
+ * is preserved.
+ * ====================================================
+ */
+
+#ifndef lint
+static char rcsid[] = "$FreeBSD: src/lib/msun/src/s_copysign.c,v 1.9 2003/07/23 04:53:46 peter Exp $";
+#endif
+
+/*
+ * copysign(double x, double y)
+ * copysign(x,y) returns a value with the magnitude of x and
+ * with the sign bit of y.
+ */
+
+#include "math.h"
+#include "math_private.h"
+
+double
+copysign(double x, double y)
+{
+ u_int32_t hx,hy;
+ GET_HIGH_WORD(hx,x);
+ GET_HIGH_WORD(hy,y);
+ SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
+ return x;
+}