xref: /dflybsd-src/contrib/openbsd_libm/src/s_copysignf.c (revision 4382f29d99a100bd77a81697c2f699c11f6a472a)
1*05a0b428SJohn Marino /* s_copysignf.c -- float version of s_copysign.c.
2*05a0b428SJohn Marino  * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
3*05a0b428SJohn Marino  */
4*05a0b428SJohn Marino 
5*05a0b428SJohn Marino /*
6*05a0b428SJohn Marino  * ====================================================
7*05a0b428SJohn Marino  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
8*05a0b428SJohn Marino  *
9*05a0b428SJohn Marino  * Developed at SunPro, a Sun Microsystems, Inc. business.
10*05a0b428SJohn Marino  * Permission to use, copy, modify, and distribute this
11*05a0b428SJohn Marino  * software is freely granted, provided that this notice
12*05a0b428SJohn Marino  * is preserved.
13*05a0b428SJohn Marino  * ====================================================
14*05a0b428SJohn Marino  */
15*05a0b428SJohn Marino 
16*05a0b428SJohn Marino /*
17*05a0b428SJohn Marino  * copysignf(float x, float y)
18*05a0b428SJohn Marino  * copysignf(x,y) returns a value with the magnitude of x and
19*05a0b428SJohn Marino  * with the sign bit of y.
20*05a0b428SJohn Marino  */
21*05a0b428SJohn Marino 
22*05a0b428SJohn Marino #include "math.h"
23*05a0b428SJohn Marino #include "math_private.h"
24*05a0b428SJohn Marino 
25*05a0b428SJohn Marino float
copysignf(float x,float y)26*05a0b428SJohn Marino copysignf(float x, float y)
27*05a0b428SJohn Marino {
28*05a0b428SJohn Marino 	u_int32_t ix,iy;
29*05a0b428SJohn Marino 	GET_FLOAT_WORD(ix,x);
30*05a0b428SJohn Marino 	GET_FLOAT_WORD(iy,y);
31*05a0b428SJohn Marino 	SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000));
32*05a0b428SJohn Marino         return x;
33*05a0b428SJohn Marino }
34