source: trunk/gcc/libjava/java/lang/w_remainder.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: 2.3 KB
Line 
1
2/* @(#)w_remainder.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<<rint>>, <<rintf>>, <<remainder>>, <<remainderf>>---round and remainder
17INDEX
18 rint
19INDEX
20 rintf
21INDEX
22 remainder
23INDEX
24 remainderf
25
26ANSI_SYNOPSIS
27 #include <math.h>
28 double rint(double <[x]>);
29 float rintf(float <[x]>);
30 double remainder(double <[x]>, double <[y]>);
31 float remainderf(float <[x]>, float <[y]>);
32
33TRAD_SYNOPSIS
34 #include <math.h>
35 double rint(<[x]>)
36 double <[x]>;
37 float rintf(<[x]>)
38 float <[x]>;
39 double remainder(<[x]>,<[y]>)
40 double <[x]>, <[y]>;
41 float remainderf(<[x]>,<[y]>)
42 float <[x]>, <[y]>;
43
44DESCRIPTION
45<<rint>> and <<rintf>> returns their argument rounded to the nearest
46integer. <<remainder>> and <<remainderf>> find the remainder of
47<[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2.
48
49RETURNS
50<<rint>> and <<remainder>> return the integer result as a double.
51
52PORTABILITY
53<<rint>> and <<remainder>> are System V release 4. <<rintf>> and
54<<remainderf>> are extensions.
55
56*/
57
58/*
59 * wrapper remainder(x,p)
60 */
61
62#include "fdlibm.h"
63#include <errno.h>
64
65#ifndef _DOUBLE_IS_32BITS
66
67#ifdef __STDC__
68 double remainder(double x, double y) /* wrapper remainder */
69#else
70 double remainder(x,y) /* wrapper remainder */
71 double x,y;
72#endif
73{
74#ifdef _IEEE_LIBM
75 return __ieee754_remainder(x,y);
76#else
77 double z;
78 struct exception exc;
79 z = __ieee754_remainder(x,y);
80 if(_LIB_VERSION == _IEEE_ || isnan(y)) return z;
81 if(y==0.0) {
82 /* remainder(x,0) */
83 exc.type = DOMAIN;
84 exc.name = "remainder";
85 exc.err = 0;
86 exc.arg1 = x;
87 exc.arg2 = y;
88 exc.retval = 0.0/0.0;
89 if (_LIB_VERSION == _POSIX_)
90 errno = EDOM;
91 else if (!matherr(&exc)) {
92 errno = EDOM;
93 }
94 if (exc.err != 0)
95 errno = exc.err;
96 return exc.retval;
97 } else
98 return z;
99#endif
100}
101
102#endif /* defined(_DOUBLE_IS_32BITS) */
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
Note: See TracBrowser for help on using the repository browser.