Mercurial > cpython-lru_cache-weakref
annotate Modules/mathmodule.c @ 892:11ea669c231e legacy-trunk
Documented new contents of lib5.tex
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 03 Jun 1992 17:56:44 +0000 |
| parents | 0cd197947d81 |
| children | c4cd0d9d8281 |
| rev | line source |
|---|---|
| 145 | 1 /*********************************************************** |
|
795
0cd197947d81
Copyright for 1992 added
Guido van Rossum <guido@python.org>
parents:
748
diff
changeset
|
2 Copyright 1991, 1992 by Stichting Mathematisch Centrum, Amsterdam, The |
| 145 | 3 Netherlands. |
| 4 | |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
| 6 | 25 /* Math module -- standard C math library functions, pi and e */ |
| 26 | |
| 86 | 27 #include "allobjects.h" |
| 6 | 28 |
| 92 | 29 #include <errno.h> |
| 30 #ifndef errno | |
| 31 extern int errno; | |
| 32 #endif | |
| 33 | |
| 6 | 34 #include "modsupport.h" |
| 35 | |
| 86 | 36 #include <math.h> |
| 37 | |
|
591
9276b3ee3936
Get rid of AMOEBA deps; add declaration of fmod() if __STDC__ is not defined.
Guido van Rossum <guido@python.org>
parents:
498
diff
changeset
|
38 #ifndef __STDC__ |
| 748 | 39 extern double fmod PROTO((double, double)); |
|
591
9276b3ee3936
Get rid of AMOEBA deps; add declaration of fmod() if __STDC__ is not defined.
Guido van Rossum <guido@python.org>
parents:
498
diff
changeset
|
40 #endif |
|
9276b3ee3936
Get rid of AMOEBA deps; add declaration of fmod() if __STDC__ is not defined.
Guido van Rossum <guido@python.org>
parents:
498
diff
changeset
|
41 |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
42 #ifdef HUGE_VAL |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
43 #define CHECK(x) if (errno != 0) ; \ |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
44 else if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \ |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
45 else errno = ERANGE |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
46 #else |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
47 #define CHECK(x) /* Don't know how to check */ |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
48 #endif |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
49 |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
50 static object * |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
51 math_error() |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
52 { |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
53 if (errno == EDOM) |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
54 err_setstr(ValueError, "math domain error"); |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
55 else if (errno == ERANGE) |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
56 err_setstr(OverflowError, "math range error"); |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
57 else |
|
679
6a60342c3107
Get rid of RuntimeError.
Guido van Rossum <guido@python.org>
parents:
591
diff
changeset
|
58 err_errno(ValueError); /* Unexpected math error */ |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
59 return NULL; |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
60 } |
|
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
61 |
| 6 | 62 static object * |
| 63 math_1(args, func) | |
| 64 object *args; | |
| 65 double (*func) FPROTO((double)); | |
| 66 { | |
| 67 double x; | |
| 68 if (!getdoublearg(args, &x)) | |
| 69 return NULL; | |
| 70 errno = 0; | |
| 71 x = (*func)(x); | |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
72 CHECK(x); |
| 6 | 73 if (errno != 0) |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
74 return math_error(); |
| 6 | 75 else |
| 76 return newfloatobject(x); | |
| 77 } | |
| 78 | |
| 79 static object * | |
| 80 math_2(args, func) | |
| 81 object *args; | |
| 82 double (*func) FPROTO((double, double)); | |
| 83 { | |
| 84 double x, y; | |
| 85 if (!get2doublearg(args, &x, &y)) | |
| 86 return NULL; | |
| 87 errno = 0; | |
| 88 x = (*func)(x, y); | |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
89 CHECK(x); |
| 6 | 90 if (errno != 0) |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
91 return math_error(); |
| 6 | 92 else |
| 93 return newfloatobject(x); | |
| 94 } | |
| 95 | |
| 96 #define FUNC1(stubname, func) \ | |
| 97 static object * stubname(self, args) object *self, *args; { \ | |
| 98 return math_1(args, func); \ | |
| 99 } | |
| 100 | |
| 101 #define FUNC2(stubname, func) \ | |
| 102 static object * stubname(self, args) object *self, *args; { \ | |
| 103 return math_2(args, func); \ | |
| 104 } | |
| 105 | |
| 106 FUNC1(math_acos, acos) | |
| 107 FUNC1(math_asin, asin) | |
| 108 FUNC1(math_atan, atan) | |
| 109 FUNC2(math_atan2, atan2) | |
| 110 FUNC1(math_ceil, ceil) | |
| 111 FUNC1(math_cos, cos) | |
| 112 FUNC1(math_cosh, cosh) | |
| 113 FUNC1(math_exp, exp) | |
| 114 FUNC1(math_fabs, fabs) | |
| 115 FUNC1(math_floor, floor) | |
| 116 FUNC2(math_fmod, fmod) | |
| 117 FUNC1(math_log, log) | |
| 118 FUNC1(math_log10, log10) | |
|
320
26426c42a162
Add some err_errno calls that were missing
Guido van Rossum <guido@python.org>
parents:
289
diff
changeset
|
119 #ifdef MPW_3_1 /* This hack is needed for MPW 3.1 but not for 3.2 ... */ |
|
289
c4c278c56e90
Apparently MPW has power() instead of pow().
Guido van Rossum <guido@python.org>
parents:
168
diff
changeset
|
120 FUNC2(math_pow, power) |
|
c4c278c56e90
Apparently MPW has power() instead of pow().
Guido van Rossum <guido@python.org>
parents:
168
diff
changeset
|
121 #else |
| 6 | 122 FUNC2(math_pow, pow) |
|
289
c4c278c56e90
Apparently MPW has power() instead of pow().
Guido van Rossum <guido@python.org>
parents:
168
diff
changeset
|
123 #endif |
| 6 | 124 FUNC1(math_sin, sin) |
| 125 FUNC1(math_sinh, sinh) | |
| 126 FUNC1(math_sqrt, sqrt) | |
| 127 FUNC1(math_tan, tan) | |
| 128 FUNC1(math_tanh, tanh) | |
| 129 | |
|
438
64bc8a284fb3
Added PROTO macro where needed.
Guido van Rossum <guido@python.org>
parents:
407
diff
changeset
|
130 double frexp PROTO((double, int *)); |
|
64bc8a284fb3
Added PROTO macro where needed.
Guido van Rossum <guido@python.org>
parents:
407
diff
changeset
|
131 double ldexp PROTO((double, int)); |
|
64bc8a284fb3
Added PROTO macro where needed.
Guido van Rossum <guido@python.org>
parents:
407
diff
changeset
|
132 double modf PROTO((double, double *)); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
133 |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
134 static object * |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
135 math_frexp(self, args) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
136 object *self; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
137 object *args; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
138 { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
139 object *v; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
140 double x; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
141 int i; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
142 if (!getdoublearg(args, &x)) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
143 return NULL; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
144 errno = 0; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
145 x = frexp(x, &i); |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
146 CHECK(x); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
147 if (errno != 0) |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
148 return math_error(); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
149 v = newtupleobject(2); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
150 if (v != NULL) { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
151 settupleitem(v, 0, newfloatobject(x)); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
152 settupleitem(v, 1, newintobject((long)i)); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
153 if (err_occurred()) { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
154 DECREF(v); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
155 v = NULL; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
156 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
157 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
158 return v; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
159 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
160 |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
161 static object * |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
162 math_ldexp(self, args) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
163 object *self; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
164 object *args; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
165 { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
166 double x, y; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
167 /* Cheat -- allow float as second argument */ |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
168 if (!get2doublearg(args, &x, &y)) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
169 return NULL; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
170 errno = 0; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
171 x = ldexp(x, (int)y); |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
172 CHECK(x); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
173 if (errno != 0) |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
174 return math_error(); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
175 else |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
176 return newfloatobject(x); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
177 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
178 |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
179 static object * |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
180 math_modf(self, args) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
181 object *self; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
182 object *args; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
183 { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
184 object *v; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
185 double x, y; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
186 if (!getdoublearg(args, &x)) |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
187 return NULL; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
188 errno = 0; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
189 x = modf(x, &y); |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
190 CHECK(x); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
191 if (errno != 0) |
|
498
56bb1067a880
Improve error handling.
Guido van Rossum <guido@python.org>
parents:
438
diff
changeset
|
192 return math_error(); |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
193 v = newtupleobject(2); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
194 if (v != NULL) { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
195 settupleitem(v, 0, newfloatobject(x)); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
196 settupleitem(v, 1, newfloatobject(y)); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
197 if (err_occurred()) { |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
198 DECREF(v); |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
199 v = NULL; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
200 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
201 } |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
202 return v; |
|
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
203 } |
| 6 | 204 |
| 205 static struct methodlist math_methods[] = { | |
| 206 {"acos", math_acos}, | |
| 207 {"asin", math_asin}, | |
| 208 {"atan", math_atan}, | |
| 209 {"atan2", math_atan2}, | |
| 210 {"ceil", math_ceil}, | |
| 211 {"cos", math_cos}, | |
| 212 {"cosh", math_cosh}, | |
| 213 {"exp", math_exp}, | |
| 214 {"fabs", math_fabs}, | |
| 215 {"floor", math_floor}, | |
| 216 {"fmod", math_fmod}, | |
|
407
9b3d557665a9
Added frexp, ldexp, modf, fmod.
Guido van Rossum <guido@python.org>
parents:
320
diff
changeset
|
217 {"frexp", math_frexp}, |
| 6 | 218 {"ldexp", math_ldexp}, |
| 219 {"log", math_log}, | |
| 220 {"log10", math_log10}, | |
| 221 {"modf", math_modf}, | |
| 222 {"pow", math_pow}, | |
| 223 {"sin", math_sin}, | |
| 224 {"sinh", math_sinh}, | |
| 225 {"sqrt", math_sqrt}, | |
| 226 {"tan", math_tan}, | |
| 227 {"tanh", math_tanh}, | |
| 228 {NULL, NULL} /* sentinel */ | |
| 229 }; | |
| 230 | |
| 231 void | |
| 232 initmath() | |
| 233 { | |
| 234 object *m, *d, *v; | |
|
42
4835c2d38b84
Take out duplication of code in initmodule().
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
235 |
|
4835c2d38b84
Take out duplication of code in initmodule().
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
236 m = initmodule("math", math_methods); |
| 6 | 237 d = getmoduledict(m); |
|
75
85eed060a46c
DECREF pi and e after inserting in symbol table.
Guido van Rossum <guido@python.org>
parents:
42
diff
changeset
|
238 dictinsert(d, "pi", v = newfloatobject(atan(1.0) * 4.0)); |
|
85eed060a46c
DECREF pi and e after inserting in symbol table.
Guido van Rossum <guido@python.org>
parents:
42
diff
changeset
|
239 DECREF(v); |
|
85eed060a46c
DECREF pi and e after inserting in symbol table.
Guido van Rossum <guido@python.org>
parents:
42
diff
changeset
|
240 dictinsert(d, "e", v = newfloatobject(exp(1.0))); |
|
85eed060a46c
DECREF pi and e after inserting in symbol table.
Guido van Rossum <guido@python.org>
parents:
42
diff
changeset
|
241 DECREF(v); |
| 6 | 242 } |
