src/libm/s_copysign.c
changeset 2756 a98604b691c8
child 3162 dc1eb82ffdaa
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/libm/s_copysign.c	Mon Sep 15 06:33:23 2008 +0000
     1.3 @@ -0,0 +1,42 @@
     1.4 +/* @(#)s_copysign.c 5.1 93/09/24 */
     1.5 +/*
     1.6 + * ====================================================
     1.7 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
     1.8 + *
     1.9 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    1.10 + * Permission to use, copy, modify, and distribute this
    1.11 + * software is freely granted, provided that this notice
    1.12 + * is preserved.
    1.13 + * ====================================================
    1.14 + */
    1.15 +
    1.16 +#if defined(LIBM_SCCS) && !defined(lint)
    1.17 +static char rcsid[] =
    1.18 +    "$NetBSD: s_copysign.c,v 1.8 1995/05/10 20:46:57 jtc Exp $";
    1.19 +#endif
    1.20 +
    1.21 +/*
    1.22 + * copysign(double x, double y)
    1.23 + * copysign(x,y) returns a value with the magnitude of x and
    1.24 + * with the sign bit of y.
    1.25 + */
    1.26 +
    1.27 +#include "math.h"
    1.28 +#include "math_private.h"
    1.29 +
    1.30 +libm_hidden_proto(copysign)
    1.31 +#ifdef __STDC__
    1.32 +     double copysign(double x, double y)
    1.33 +#else
    1.34 +     double copysign(x, y)
    1.35 +     double x, y;
    1.36 +#endif
    1.37 +{
    1.38 +    u_int32_t hx, hy;
    1.39 +    GET_HIGH_WORD(hx, x);
    1.40 +    GET_HIGH_WORD(hy, y);
    1.41 +    SET_HIGH_WORD(x, (hx & 0x7fffffff) | (hy & 0x80000000));
    1.42 +    return x;
    1.43 +}
    1.44 +
    1.45 +libm_hidden_def(copysign)