Back to index

glibc  2.9
s_copysign.c
Go to the documentation of this file.
00001 /* @(#)s_copysign.c 5.1 93/09/24 */
00002 /*
00003  * ====================================================
00004  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
00005  *
00006  * Developed at SunPro, a Sun Microsystems, Inc. business.
00007  * Permission to use, copy, modify, and distribute this
00008  * software is freely granted, provided that this notice
00009  * is preserved.
00010  * ====================================================
00011  */
00012 
00013 #if defined(LIBM_SCCS) && !defined(lint)
00014 static char rcsid[] = "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $";
00015 #endif
00016 
00017 /*
00018  * copysign(double x, double y)
00019  * copysign(x,y) returns a value with the magnitude of x and
00020  * with the sign bit of y.
00021  */
00022 
00023 #include "math.h"
00024 #include "math_private.h"
00025 
00026 #ifdef __STDC__
00027        double __copysign(double x, double y)
00028 #else
00029        double __copysign(x,y)
00030        double x,y;
00031 #endif
00032 {
00033        u_int32_t hx,hy;
00034        GET_HIGH_WORD(hx,x);
00035        GET_HIGH_WORD(hy,y);
00036        SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
00037         return x;
00038 }
00039 weak_alias (__copysign, copysign)
00040 #ifdef NO_LONG_DOUBLE
00041 strong_alias (__copysign, __copysignl)
00042 weak_alias (__copysign, copysignl)
00043 #endif