source: trunk/gcc/libjava/java/lang/s_copysign.c

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.8 KB
Line 
1
2/* @(#)s_copysign.c 5.1 93/09/24 */
3/*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
6 *
7 * Developed at SunPro, a Sun Microsystems, Inc. business.
8 * Permission to use, copy, modify, and distribute this
9 * software is freely granted, provided that this notice
10 * is preserved.
11 * ====================================================
12 */
13
14/*
15FUNCTION
16<<copysign>>, <<copysignf>>---sign of <[y]>, magnitude of <[x]>
17
18INDEX
19 copysign
20INDEX
21 copysignf
22
23ANSI_SYNOPSIS
24 #include <math.h>
25 double copysign (double <[x]>, double <[y]>);
26 float copysignf (float <[x]>, float <[y]>);
27
28TRAD_SYNOPSIS
29 #include <math.h>
30 double copysign (<[x]>, <[y]>)
31 double <[x]>;
32 double <[y]>;
33
34 float copysignf (<[x]>, <[y]>)
35 float <[x]>;
36 float <[y]>;
37
38DESCRIPTION
39<<copysign>> constructs a number with the magnitude (absolute value)
40of its first argument, <[x]>, and the sign of its second argument,
41<[y]>.
42
43<<copysignf>> does the same thing; the two functions differ only in
44the type of their arguments and result.
45
46RETURNS
47<<copysign>> returns a <<double>> with the magnitude of
48<[x]> and the sign of <[y]>.
49<<copysignf>> returns a <<float>> with the magnitude of
50<[x]> and the sign of <[y]>.
51
52PORTABILITY
53<<copysign>> is not required by either ANSI C or the System V Interface
54Definition (Issue 2).
55
56*/
57
58/*
59 * copysign(double x, double y)
60 * copysign(x,y) returns a value with the magnitude of x and
61 * with the sign bit of y.
62 */
63
64#include "fdlibm.h"
65
66#ifndef _DOUBLE_IS_32BITS
67
68#ifdef __STDC__
69 double copysign(double x, double y)
70#else
71 double copysign(x,y)
72 double x,y;
73#endif
74{
75 uint32_t hx,hy;
76 GET_HIGH_WORD(hx,x);
77 GET_HIGH_WORD(hy,y);
78 SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
79 return x;
80}
81
82#endif /* _DOUBLE_IS_32BITS */
Note: See TracBrowser for help on using the repository browser.