2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / java / lang / w_remainder.c
bloba06be0e7b307517754142d7d92c599b0bbe5bd77
2 /* @(#)w_remainder.c 5.1 93/09/24 */
3 /*
4 * ====================================================
5 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
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 * ====================================================
15 FUNCTION
16 <<rint>>, <<rintf>>, <<remainder>>, <<remainderf>>---round and remainder
17 INDEX
18 rint
19 INDEX
20 rintf
21 INDEX
22 remainder
23 INDEX
24 remainderf
26 ANSI_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]>);
33 TRAD_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]>;
44 DESCRIPTION
45 <<rint>> and <<rintf>> returns their argument rounded to the nearest
46 integer. <<remainder>> and <<remainderf>> find the remainder of
47 <[x]>/<[y]>; this value is in the range -<[y]>/2 .. +<[y]>/2.
49 RETURNS
50 <<rint>> and <<remainder>> return the integer result as a double.
52 PORTABILITY
53 <<rint>> and <<remainder>> are System V release 4. <<rintf>> and
54 <<remainderf>> are extensions.
58 /*
59 * wrapper remainder(x,p)
62 #include "fdlibm.h"
63 #include <errno.h>
65 #ifndef _DOUBLE_IS_32BITS
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
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;
94 if (exc.err != 0)
95 errno = exc.err;
96 return exc.retval;
97 } else
98 return z;
99 #endif
102 #endif /* defined(_DOUBLE_IS_32BITS) */