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