|
0
|
1 //=========================================================================== |
|
|
2 // |
|
|
3 // w_exp.c |
|
|
4 // |
|
|
5 // Part of the standard mathematical function library |
|
|
6 // |
|
|
7 //=========================================================================== |
|
|
8 //####COPYRIGHTBEGIN#### |
|
|
9 // |
|
|
10 // ------------------------------------------- |
|
|
11 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
12 // Version 1.0 (the "License"); you may not use this file except in |
|
|
13 // compliance with the License. You may obtain a copy of the License at |
|
|
14 // http://sourceware.cygnus.com/ecos |
|
|
15 // |
|
|
16 // Software distributed under the License is distributed on an "AS IS" |
|
|
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
18 // License for the specific language governing rights and limitations under |
|
|
19 // the License. |
|
|
20 // |
|
|
21 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
22 // September 30, 1998. |
|
|
23 // |
|
|
24 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //=========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
2
|
32 // Author(s): jlarmour |
|
|
33 // Contributors: jlarmour |
|
0
|
34 // Date: 1998-02-13 |
|
|
35 // Purpose: |
|
|
36 // Description: |
|
|
37 // Usage: |
|
|
38 // |
|
|
39 //####DESCRIPTIONEND#### |
|
|
40 // |
|
|
41 //=========================================================================== |
|
|
42 |
|
|
43 // CONFIGURATION |
|
|
44 |
|
|
45 #include <pkgconf/libm.h> // Configuration header |
|
|
46 |
|
|
47 // Include the Math library? |
|
|
48 #ifdef CYGPKG_LIBM |
|
|
49 |
|
|
50 // Derived from code with the following copyright |
|
|
51 |
|
|
52 |
|
|
53 /* @(#)w_exp.c 1.3 95/01/18 */ |
|
|
54 /* |
|
|
55 * ==================================================== |
|
|
56 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. |
|
|
57 * |
|
|
58 * Developed at SunSoft, a Sun Microsystems, Inc. business. |
|
|
59 * Permission to use, copy, modify, and distribute this |
|
|
60 * software is freely granted, provided that this notice |
|
|
61 * is preserved. |
|
|
62 * ==================================================== |
|
|
63 */ |
|
|
64 |
|
|
65 /* |
|
|
66 * wrapper exp(x) |
|
|
67 */ |
|
|
68 |
|
|
69 #include "mathincl/fdlibm.h" |
|
|
70 |
|
|
71 static const double |
|
|
72 o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */ |
|
|
73 u_threshold= -7.45133219101941108420e+02; /* 0xc0874910, 0xD52D3051 */ |
|
|
74 |
|
|
75 double exp(double x) /* wrapper exp */ |
|
|
76 { |
|
|
77 #ifdef CYGSEM_LIBM_COMPAT_IEEE_ONLY |
|
|
78 return __ieee754_exp(x); |
|
|
79 #else |
|
|
80 double z; |
|
|
81 z = __ieee754_exp(x); |
|
|
82 if(cyg_libm_get_compat_mode() == CYGNUM_LIBM_COMPAT_IEEE) return z; |
|
|
83 if(finite(x)) { |
|
|
84 if(x>o_threshold) |
|
|
85 return __kernel_standard(x,x,6); /* exp overflow */ |
|
|
86 else if(x<u_threshold) |
|
|
87 return __kernel_standard(x,x,7); /* exp underflow */ |
|
|
88 } |
|
|
89 return z; |
|
|
90 #endif |
|
|
91 } |
|
|
92 |
|
|
93 #endif // ifdef CYGPKG_LIBM |
|
|
94 |
|
|
95 // EOF w_exp.c |