xref: /freebsd/lib/msun/src/s_copysign.c (revision 4b9d6057)
1 /*
2  * ====================================================
3  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
4  *
5  * Developed at SunPro, a Sun Microsystems, Inc. business.
6  * Permission to use, copy, modify, and distribute this
7  * software is freely granted, provided that this notice
8  * is preserved.
9  * ====================================================
10  */
11 
12 #include <sys/cdefs.h>
13 /*
14  * copysign(double x, double y)
15  * copysign(x,y) returns a value with the magnitude of x and
16  * with the sign bit of y.
17  */
18 
19 #include "math.h"
20 #include "math_private.h"
21 
22 double
23 copysign(double x, double y)
24 {
25 	u_int32_t hx,hy;
26 	GET_HIGH_WORD(hx,x);
27 	GET_HIGH_WORD(hy,y);
28 	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
29         return x;
30 }
31