Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
 
2
/*
3
 * ====================================================
4
 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * Developed at SunPro, a Sun Microsystems, Inc. business.
7
 * Permission to use, copy, modify, and distribute this
8
 * software is freely granted, provided that this notice
9
 * is preserved.
10
 * ====================================================
11
 */
12
13
 
14
FUNCTION
15
	<>, <>---base 10 logarithms
16
17
 
18
log10
19
INDEX
20
log10f
21
22
 
23
	#include 
24
	double log10(double <[x]>);
25
	float log10f(float <[x]>);
26
27
 
28
	#include 
29
	double log10(<[x]>)
30
	double <[x]>;
31
32
 
33
	float <[x]>;
34
35
 
36
<> returns the base 10 logarithm of <[x]>.
37
It is implemented as <) / log(10)>>.
38
39
 
40
41
 
42
<> and <> return the calculated value.
43
44
 
45
46
 
47
<> is ANSI C.  <> is an extension.
48
49
 
50
51
 
52
 * wrapper log10(X)
53
 */
54
55
 
56
#include 
57
58
 
59
60
 
61
	double log10(double x)		/* wrapper log10 */
62
#else
63
	double log10(x)			/* wrapper log10 */
64
	double x;
65
#endif
66
{
67
#ifdef _IEEE_LIBM
68
	return __ieee754_log10(x);
69
#else
70
	double z;
71
	struct exception exc;
72
	z = __ieee754_log10(x);
73
	if(_LIB_VERSION == _IEEE_ || isnan(x)) return z;
74
	if(x<=0.0) {
75
#ifndef HUGE_VAL
76
#define HUGE_VAL inf
77
	    double inf = 0.0;
78
79
 
80
#endif
81
	    exc.name = "log10";
82
	    exc.err = 0;
83
	    exc.arg1 = x;
84
	    exc.arg2 = x;
85
	    if (_LIB_VERSION == _SVID_)
86
               exc.retval = -HUGE;
87
	    else
88
	       exc.retval = -HUGE_VAL;
89
	    if(x==0.0) {
90
	        /* log10(0) */
91
	        exc.type = SING;
92
	        if (_LIB_VERSION == _POSIX_)
93
	           errno = ERANGE;
94
	        else if (!matherr(&exc)) {
95
	           errno = ERANGE;
96
	        }
97
	    } else {
98
	        /* log10(x<0) */
99
	        exc.type = DOMAIN;
100
	        if (_LIB_VERSION == _POSIX_)
101
	           errno = EDOM;
102
	        else if (!matherr(&exc)) {
103
	           errno = EDOM;
104
	        }
105
                exc.retval = nan("");
106
            }
107
	    if (exc.err != 0)
108
               errno = exc.err;
109
            return exc.retval;
110
	} else
111
	    return z;
112
#endif
113
}
114
115
 
116