source: trunk/gcc/libjava/java/lang/w_log.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.5 KB
Line 
1
2/* @(#)w_log.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 <<log>>, <<logf>>---natural logarithms
17
18INDEX
19 log
20INDEX
21 logf
22
23ANSI_SYNOPSIS
24 #include <math.h>
25 double log(double <[x]>);
26 float logf(float <[x]>);
27
28TRAD_SYNOPSIS
29 #include <math.h>
30 double log(<[x]>);
31 double <[x]>;
32
33 float logf(<[x]>);
34 float <[x]>;
35
36DESCRIPTION
37Return the natural logarithm of <[x]>, that is, its logarithm base e
38(where e is the base of the natural system of logarithms, 2.71828@dots{}).
39<<log>> and <<logf>> are identical save for the return and argument types.
40
41You can use the (non-ANSI) function <<matherr>> to specify error
42handling for these functions.
43
44RETURNS
45Normally, returns the calculated value. When <[x]> is zero, the
46returned value is <<-HUGE_VAL>> and <<errno>> is set to <<ERANGE>>.
47When <[x]> is negative, the returned value is <<-HUGE_VAL>> and
48<<errno>> is set to <<EDOM>>. You can control the error behavior via
49<<matherr>>.
50
51PORTABILITY
52<<log>> is ANSI, <<logf>> is an extension.
53*/
54
55/*
56 * wrapper log(x)
57 */
58
59#include "fdlibm.h"
60#include <errno.h>
61
62#ifndef _DOUBLE_IS_32BITS
63
64#ifdef __STDC__
65 double log(double x) /* wrapper log */
66#else
67 double log(x) /* wrapper log */
68 double x;
69#endif
70{
71#ifdef _IEEE_LIBM
72 return __ieee754_log(x);
73#else
74 double z;
75 struct exception exc;
76 z = __ieee754_log(x);
77 if(_LIB_VERSION == _IEEE_ || isnan(x) || x > 0.0) return z;
78#ifndef HUGE_VAL
79#define HUGE_VAL inf
80 double inf = 0.0;
81
82 SET_HIGH_WORD(inf,0x7ff00000); /* set inf to infinite */
83#endif
84 exc.name = "log";
85 exc.err = 0;
86 exc.arg1 = x;
87 exc.arg2 = x;
88 if (_LIB_VERSION == _SVID_)
89 exc.retval = -HUGE;
90 else
91 exc.retval = -HUGE_VAL;
92 if(x==0.0) {
93 /* log(0) */
94 exc.type = SING;
95 if (_LIB_VERSION == _POSIX_)
96 errno = ERANGE;
97 else if (!matherr(&exc)) {
98 errno = EDOM;
99 }
100 } else {
101 /* log(x<0) */
102 exc.type = DOMAIN;
103 if (_LIB_VERSION == _POSIX_)
104 errno = EDOM;
105 else if (!matherr(&exc)) {
106 errno = EDOM;
107 }
108 }
109 if (exc.err != 0)
110 errno = exc.err;
111 return exc.retval;
112#endif
113}
114
115#endif /* defined(_DOUBLE_IS_32BITS) */
Note: See TracBrowser for help on using the repository browser.