OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libm/] [math/] [w_remainder.c] - Blame information for rev 39

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 lampret
 
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
/*
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
25
 
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]>);
32
 
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]>;
43
 
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.
48
 
49
RETURNS
50
<<rint>> and <<remainder>> return the integer result as a double.
51
 
52
PORTABILITY
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.retval = 0.0/0.0;
86
            if (_LIB_VERSION == _POSIX_)
87
               errno = EDOM;
88
            else if (!matherr(&exc)) {
89
               errno = EDOM;
90
            }
91
            if (exc.err != 0)
92
               errno = exc.err;
93
            return exc.retval;
94
        } else
95
            return z;
96
#endif
97
}
98
 
99
#endif /* defined(_DOUBLE_IS_32BITS) */
100
 
101
 
102
 
103
 
104
 
105
 
106
 
107
 
108
 
109
 
110
 
111
 
112
 
113
 
114
 
115
 
116
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.