sl@0: /* S_CPYSGN.C sl@0: * sl@0: * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: */ sl@0: sl@0: sl@0: /* @(#)s_copysign.c 5.1 93/09/24 */ sl@0: /* sl@0: * ==================================================== sl@0: * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. sl@0: * sl@0: * Developed at SunPro, a Sun Microsystems, Inc. business. sl@0: * Permission to use, copy, modify, and distribute this sl@0: * software is freely granted, provided that this notice sl@0: * is preserved. sl@0: * ==================================================== sl@0: */ sl@0: sl@0: /* sl@0: FUNCTION sl@0: <>, <>---sign of <[y]>, magnitude of <[x]> sl@0: sl@0: INDEX sl@0: copysign sl@0: INDEX sl@0: copysignf sl@0: sl@0: ANSI_SYNOPSIS sl@0: #include sl@0: double copysign (double <[x]>, double <[y]>); sl@0: float copysignf (float <[x]>, float <[y]>); sl@0: sl@0: TRAD_SYNOPSIS sl@0: #include sl@0: double copysign (<[x]>, <[y]>) sl@0: double <[x]>; sl@0: double <[y]>; sl@0: sl@0: float copysignf (<[x]>, <[y]>) sl@0: float <[x]>; sl@0: float <[y]>; sl@0: sl@0: DESCRIPTION sl@0: <> constructs a number with the magnitude (absolute value) sl@0: of its first argument, <[x]>, and the sign of its second argument, sl@0: <[y]>. sl@0: sl@0: <> does the same thing; the two functions differ only in sl@0: the type of their arguments and result. sl@0: sl@0: RETURNS sl@0: <> returns a <> with the magnitude of sl@0: <[x]> and the sign of <[y]>. sl@0: <> returns a <> with the magnitude of sl@0: <[x]> and the sign of <[y]>. sl@0: sl@0: PORTABILITY sl@0: <> is not required by either ANSI C or the System V Interface sl@0: Definition (Issue 2). sl@0: sl@0: */ sl@0: sl@0: /* sl@0: * copysign(double x, double y) sl@0: * copysign(x,y) returns a value with the magnitude of x and sl@0: * with the sign bit of y. sl@0: */ sl@0: sl@0: #include "FDLIBM.H" sl@0: sl@0: /** sl@0: Constructs a number with the magnitude (absolute value) sl@0: of its first argument, x, and the sign of its second argument y. sl@0: @return a value with the magnitude of x and with the sign bit of y. sl@0: @param x magnitude sl@0: @param y sign bit sl@0: */ sl@0: EXPORT_C double copysign(double x, double y) __SOFTFP sl@0: { sl@0: __uint32_t hx,hy; sl@0: GET_HIGH_WORD(hx,x); sl@0: GET_HIGH_WORD(hy,y); sl@0: SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000)); sl@0: return x; sl@0: }