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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libm/] [math/] [w_log10.c] - Blame information for rev 307

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

Line No. Rev Author Line
1 207 jeremybenn
 
2
/* @(#)w_log10.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
        <<log10>>, <<log10f>>---base 10 logarithms
17
 
18
INDEX
19
log10
20
INDEX
21
log10f
22
 
23
ANSI_SYNOPSIS
24
        #include <math.h>
25
        double log10(double <[x]>);
26
        float log10f(float <[x]>);
27
 
28
TRAD_SYNOPSIS
29
        #include <math.h>
30
        double log10(<[x]>)
31
        double <[x]>;
32
 
33
        float log10f(<[x]>)
34
        float <[x]>;
35
 
36
DESCRIPTION
37
<<log10>> returns the base 10 logarithm of <[x]>.
38
It is implemented as <<log(<[x]>) / log(10)>>.
39
 
40
<<log10f>> is identical, save that it takes and returns <<float>> values.
41
 
42
RETURNS
43
<<log10>> and <<log10f>> return the calculated value.
44
 
45
See the description of <<log>> for information on errors.
46
 
47
PORTABILITY
48
<<log10>> is ANSI C.  <<log10f>> is an extension.
49
 
50
 */
51
 
52
/*
53
 * wrapper log10(X)
54
 */
55
 
56
#include "fdlibm.h"
57
#include <errno.h>
58
 
59
#ifndef _DOUBLE_IS_32BITS
60
 
61
#ifdef __STDC__
62
        double log10(double x)          /* wrapper log10 */
63
#else
64
        double log10(x)                 /* wrapper log10 */
65
        double x;
66
#endif
67
{
68
#ifdef _IEEE_LIBM
69
        return __ieee754_log10(x);
70
#else
71
        double z;
72
        struct exception exc;
73
        z = __ieee754_log10(x);
74
        if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
75
        if(x<=0.0) {
76
#ifndef HUGE_VAL 
77
#define HUGE_VAL inf
78
            double inf = 0.0;
79
 
80
            SET_HIGH_WORD(inf,0x7ff00000);      /* set inf to infinite */
81
#endif
82
            exc.name = "log10";
83
            exc.err = 0;
84
            exc.arg1 = x;
85
            exc.arg2 = x;
86
            if (_LIB_VERSION == _SVID_)
87
               exc.retval = -HUGE;
88
            else
89
               exc.retval = -HUGE_VAL;
90
            if(x==0.0) {
91
                /* log10(0) */
92
                exc.type = SING;
93
                if (_LIB_VERSION == _POSIX_)
94
                   errno = ERANGE;
95
                else if (!matherr(&exc)) {
96
                   errno = ERANGE;
97
                }
98
            } else {
99
                /* log10(x<0) */
100
                exc.type = DOMAIN;
101
                if (_LIB_VERSION == _POSIX_)
102
                   errno = EDOM;
103
                else if (!matherr(&exc)) {
104
                   errno = EDOM;
105
                }
106
                exc.retval = nan("");
107
            }
108
            if (exc.err != 0)
109
               errno = exc.err;
110
            return exc.retval;
111
        } else
112
            return z;
113
#endif
114
}
115
 
116
#endif /* defined(_DOUBLE_IS_32BITS) */

powered by: WebSVN 2.1.0

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