source: trunk/gcc/libjava/java/lang/w_fmod.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_fmod.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<<fmod>>, <<fmodf>>---floating-point remainder (modulo)
17
18INDEX
19fmod
20INDEX
21fmodf
22
23ANSI_SYNOPSIS
24#include <math.h>
25double fmod(double <[x]>, double <[y]>)
26float fmodf(float <[x]>, float <[y]>)
27
28TRAD_SYNOPSIS
29#include <math.h>
30double fmod(<[x]>, <[y]>)
31double (<[x]>, <[y]>);
32
33float fmodf(<[x]>, <[y]>)
34float (<[x]>, <[y]>);
35
36DESCRIPTION
37The <<fmod>> and <<fmodf>> functions compute the floating-point
38remainder of <[x]>/<[y]> (<[x]> modulo <[y]>).
39
40RETURNS
41The <<fmod>> function returns the value
42@ifinfo
43<[x]>-<[i]>*<[y]>,
44@end ifinfo
45@tex
46$x-i\times y$,
47@end tex
48for the largest integer <[i]> such that, if <[y]> is nonzero, the
49result has the same sign as <[x]> and magnitude less than the
50magnitude of <[y]>.
51
52<<fmod(<[x]>,0)>> returns NaN, and sets <<errno>> to <<EDOM>>.
53
54You can modify error treatment for these functions using <<matherr>>.
55
56PORTABILITY
57<<fmod>> is ANSI C. <<fmodf>> is an extension.
58*/
59
60/*
61 * wrapper fmod(x,y)
62 */
63
64#include "fdlibm.h"
65#include <errno.h>
66
67#ifndef _DOUBLE_IS_32BITS
68
69#ifdef __STDC__
70 double fmod(double x, double y) /* wrapper fmod */
71#else
72 double fmod(x,y) /* wrapper fmod */
73 double x,y;
74#endif
75{
76#ifdef _IEEE_LIBM
77 return __ieee754_fmod(x,y);
78#else
79 double z;
80 struct exception exc;
81 z = __ieee754_fmod(x,y);
82 if(_LIB_VERSION == _IEEE_ ||isnan(y)||isnan(x)) return z;
83 if(y==0.0) {
84 /* fmod(x,0) */
85 exc.type = DOMAIN;
86 exc.name = "fmod";
87 exc.arg1 = x;
88 exc.arg2 = y;
89 exc.err = 0;
90 if (_LIB_VERSION == _SVID_)
91 exc.retval = x;
92 else
93 exc.retval = 0.0/0.0;
94 if (_LIB_VERSION == _POSIX_)
95 errno = EDOM;
96 else if (!matherr(&exc)) {
97 errno = EDOM;
98 }
99 if (exc.err != 0)
100 errno = exc.err;
101 return exc.retval;
102 } else
103 return z;
104#endif
105}
106
107#endif /* defined(_DOUBLE_IS_32BITS) */
Note: See TracBrowser for help on using the repository browser.