os/ossrv/genericopenlibs/cstdlib/LMATH/S_CPYSGN.C
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/cstdlib/LMATH/S_CPYSGN.C	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,86 @@
     1.4 +/* S_CPYSGN.C
     1.5 + * 
     1.6 + * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
     1.7 + * All rights reserved.
     1.8 + */
     1.9 +
    1.10 +
    1.11 +/* @(#)s_copysign.c 5.1 93/09/24 */
    1.12 +/*
    1.13 + * ====================================================
    1.14 + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    1.15 + *
    1.16 + * Developed at SunPro, a Sun Microsystems, Inc. business.
    1.17 + * Permission to use, copy, modify, and distribute this
    1.18 + * software is freely granted, provided that this notice 
    1.19 + * is preserved.
    1.20 + * ====================================================
    1.21 + */
    1.22 +
    1.23 +/*
    1.24 +FUNCTION
    1.25 +<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]>
    1.26 +
    1.27 +INDEX
    1.28 +	copysign
    1.29 +INDEX
    1.30 +	copysignf
    1.31 +
    1.32 +ANSI_SYNOPSIS
    1.33 +	#include <math.h>
    1.34 +	double copysign (double <[x]>, double <[y]>);
    1.35 +	float copysignf (float <[x]>, float <[y]>);
    1.36 +
    1.37 +TRAD_SYNOPSIS
    1.38 +	#include <math.h>
    1.39 +	double copysign (<[x]>, <[y]>)
    1.40 +	double <[x]>;
    1.41 +	double <[y]>;
    1.42 +
    1.43 +	float copysignf (<[x]>, <[y]>)
    1.44 +	float <[x]>;
    1.45 +	float <[y]>;
    1.46 +
    1.47 +DESCRIPTION
    1.48 +<<copysign>> constructs a number with the magnitude (absolute value)
    1.49 +of its first argument, <[x]>, and the sign of its second argument,
    1.50 +<[y]>.
    1.51 +
    1.52 +<<copysignf>> does the same thing; the two functions differ only in
    1.53 +the type of their arguments and result.
    1.54 +
    1.55 +RETURNS
    1.56 +<<copysign>> returns a <<double>> with the magnitude of
    1.57 +<[x]> and the sign of <[y]>.
    1.58 +<<copysignf>> returns a <<float>> with the magnitude of
    1.59 +<[x]> and the sign of <[y]>.
    1.60 +
    1.61 +PORTABILITY
    1.62 +<<copysign>> is not required by either ANSI C or the System V Interface
    1.63 +Definition (Issue 2).
    1.64 +
    1.65 +*/
    1.66 +
    1.67 +/*
    1.68 + * copysign(double x, double y)
    1.69 + * copysign(x,y) returns a value with the magnitude of x and
    1.70 + * with the sign bit of y.
    1.71 + */
    1.72 +
    1.73 +#include "FDLIBM.H"
    1.74 +
    1.75 +/**
    1.76 +Constructs a number with the magnitude (absolute value)
    1.77 +of its first argument, x, and the sign of its second argument y.
    1.78 +@return a value with the magnitude of x and with the sign bit of y.
    1.79 +@param x magnitude
    1.80 +@param y sign bit
    1.81 +*/
    1.82 +EXPORT_C double copysign(double x, double y) __SOFTFP
    1.83 +{
    1.84 +	__uint32_t hx,hy;
    1.85 +	GET_HIGH_WORD(hx,x);
    1.86 +	GET_HIGH_WORD(hy,y);
    1.87 +	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
    1.88 +        return x;
    1.89 +}