File tree Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Expand file tree Collapse file tree 2 files changed +15
-12
lines changed Original file line number Diff line number Diff line change 1
1
namespace Math;
2
2
3
+ /%
4
+ The ratio of a circle's circumference to its diameter.
5
+ %/
6
+ const dec PI = 3.141592653589793;
7
+ /%
8
+ Euler's number. The base of the natural log.
9
+ %/
10
+ const dec E = 2.718281828459045;
11
+ /%
12
+ The result of @"log10" of @"E".
13
+ %/
14
+ const dec LOG10_E = 0.434294481903251;
15
+
3
16
/%
4
17
@asm
5
18
@@ -142,8 +155,7 @@ func dec log10(dec x) {
142
155
// Finally, return
143
156
// log10(x) = ln(x) * log10(e) + b
144
157
145
- // log10(e) = 0.434294481903251
146
- ret seriesSum * 0.434294481903251 + b;
158
+ ret seriesSum * LOG10_E + b;
147
159
}
148
160
149
161
/%
@@ -156,7 +168,7 @@ This function uses @"log10" to compute the natural log.
156
168
%/
157
169
func dec ln(dec x) {
158
170
// ln(x) = log10(x) / log10(e)
159
- ret log10(x) / 0.434294481903251 ;
171
+ ret log10(x) / LOG10_E ;
160
172
}
161
173
162
174
/%
@@ -187,9 +199,6 @@ func dec log(dec x, dec base) {
187
199
Computes e ^ @"x".
188
200
%/
189
201
func dec exp(dec x) {
190
- // Temp until global constants
191
- dec E = 2.718281828459045;
192
-
193
202
// Special cases
194
203
195
204
if (x == -infinity) {
Original file line number Diff line number Diff line change @@ -11,9 +11,6 @@ Computes the sine of @"x" (in radians).
11
11
Please note that an input of @"PI" **will not** return exactly `0.0`.
12
12
%/
13
13
func dec sin(dec x) {
14
- // Temp until global constants
15
- dec PI = 3.141592653589793;
16
-
17
14
// Special cases
18
15
19
16
if (x == infinity) {
@@ -73,9 +70,6 @@ Computes the cosine of @"x" (in radians).
73
70
Please note that an input of @"PI" **will not** return exactly `-1.0`.
74
71
%/
75
72
func dec cos(dec x) {
76
- // Temp until global constants
77
- dec PI = 3.141592653589793;
78
-
79
73
ret sin(x + PI / 2.0);
80
74
}
81
75
You can’t perform that action at this time.
0 commit comments