12116Sjkh/* @(#)s_copysign.c 5.1 93/09/24 */
22116Sjkh/*
32116Sjkh * ====================================================
42116Sjkh * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
52116Sjkh *
62116Sjkh * Developed at SunPro, a Sun Microsystems, Inc. business.
72116Sjkh * Permission to use, copy, modify, and distribute this
88870Srgrimes * software is freely granted, provided that this notice
92116Sjkh * is preserved.
102116Sjkh * ====================================================
112116Sjkh */
122116Sjkh
13176451Sdas#include <sys/cdefs.h>
14176451Sdas__FBSDID("$FreeBSD$");
152116Sjkh
162116Sjkh/*
172116Sjkh * copysign(double x, double y)
182116Sjkh * copysign(x,y) returns a value with the magnitude of x and
192116Sjkh * with the sign bit of y.
202116Sjkh */
212116Sjkh
222116Sjkh#include "math.h"
232116Sjkh#include "math_private.h"
242116Sjkh
2597413Salfreddouble
26117912Spetercopysign(double x, double y)
272116Sjkh{
282116Sjkh	u_int32_t hx,hy;
292116Sjkh	GET_HIGH_WORD(hx,x);
302116Sjkh	GET_HIGH_WORD(hy,y);
312116Sjkh	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
322116Sjkh        return x;
332116Sjkh}
34