os/ossrv/genericopenlibs/cstdlib/LMATH/S_CPYSGN.C
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /* S_CPYSGN.C
     2  * 
     3  * Portions Copyright (c) 1993-1999 Nokia Corporation and/or its subsidiary(-ies).
     4  * All rights reserved.
     5  */
     6 
     7 
     8 /* @(#)s_copysign.c 5.1 93/09/24 */
     9 /*
    10  * ====================================================
    11  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    12  *
    13  * Developed at SunPro, a Sun Microsystems, Inc. business.
    14  * Permission to use, copy, modify, and distribute this
    15  * software is freely granted, provided that this notice 
    16  * is preserved.
    17  * ====================================================
    18  */
    19 
    20 /*
    21 FUNCTION
    22 <<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]>
    23 
    24 INDEX
    25 	copysign
    26 INDEX
    27 	copysignf
    28 
    29 ANSI_SYNOPSIS
    30 	#include <math.h>
    31 	double copysign (double <[x]>, double <[y]>);
    32 	float copysignf (float <[x]>, float <[y]>);
    33 
    34 TRAD_SYNOPSIS
    35 	#include <math.h>
    36 	double copysign (<[x]>, <[y]>)
    37 	double <[x]>;
    38 	double <[y]>;
    39 
    40 	float copysignf (<[x]>, <[y]>)
    41 	float <[x]>;
    42 	float <[y]>;
    43 
    44 DESCRIPTION
    45 <<copysign>> constructs a number with the magnitude (absolute value)
    46 of its first argument, <[x]>, and the sign of its second argument,
    47 <[y]>.
    48 
    49 <<copysignf>> does the same thing; the two functions differ only in
    50 the type of their arguments and result.
    51 
    52 RETURNS
    53 <<copysign>> returns a <<double>> with the magnitude of
    54 <[x]> and the sign of <[y]>.
    55 <<copysignf>> returns a <<float>> with the magnitude of
    56 <[x]> and the sign of <[y]>.
    57 
    58 PORTABILITY
    59 <<copysign>> is not required by either ANSI C or the System V Interface
    60 Definition (Issue 2).
    61 
    62 */
    63 
    64 /*
    65  * copysign(double x, double y)
    66  * copysign(x,y) returns a value with the magnitude of x and
    67  * with the sign bit of y.
    68  */
    69 
    70 #include "FDLIBM.H"
    71 
    72 /**
    73 Constructs a number with the magnitude (absolute value)
    74 of its first argument, x, and the sign of its second argument y.
    75 @return a value with the magnitude of x and with the sign bit of y.
    76 @param x magnitude
    77 @param y sign bit
    78 */
    79 EXPORT_C double copysign(double x, double y) __SOFTFP
    80 {
    81 	__uint32_t hx,hy;
    82 	GET_HIGH_WORD(hx,x);
    83 	GET_HIGH_WORD(hy,y);
    84 	SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
    85         return x;
    86 }