/
math.ooc
149 lines (121 loc) · 4.55 KB
/
math.ooc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
include math
use math
PI := 3.14159_26535_89793_23846_26433_83279
cos: extern func (Double) -> Double
sin: extern func (Double) -> Double
tan: extern func (Double) -> Double
acos: extern func (Double) -> Double
asin: extern func (Double) -> Double
atan: extern func (Double) -> Double
atan2: extern func (Double, Double) -> Double
sqrt: extern func (Double) -> Double
pow: extern func (Double, Double) -> Double
log: extern(log) func ~Double (Double) -> Double
log: extern(logf) func ~Float (Float) -> Float
log: extern(logl) func ~Long (LDouble) -> LDouble
log10: extern(log10) func ~Double (Double) -> Double
log10: extern(log10f) func ~Float (Float) -> Float
log10: extern(log10l) func ~Long (LDouble) -> LDouble
round: extern(lround) func ~dl (Double) -> Long
ceil: extern(ceil) func ~Double (Double) -> Double
ceil: extern(ceilf) func ~Float (Float) -> Float
ceil: extern(ceill) func ~Long (LDouble) -> LDouble
floor: extern(floor) func ~Double (Double) -> Double
floor: extern(floorf) func ~Float (Float) -> Float
floor: extern(floorl) func ~Long (LDouble) -> LDouble
/* I don't think math.ooc should be a bunch of global functions,
instead it should define a bunch of methods on the numeric
classes. I'm going to write these methods but leave the existing
functions alone for the sake of compatability.
For future additions please define only methods and not the
function versions to discourage use of the deprecated function
versions.
- Scott
*/
extend Double {
cos: extern(cos) func -> This
sin: extern(sin) func -> This
tan: extern(tan) func -> This
acos: extern(acos) func -> This
asin: extern(asin) func -> This
atan: extern(atan) func -> This
cosh: extern(cosh) func -> This
sinh: extern(sinh) func -> This
tanh: extern(tanh) func -> This
acosh: extern(acosh) func -> This
asinh: extern(asinh) func -> This
atanh: extern(atanh) func -> This
atan2: extern(atan2) func (This) -> This
sqrt: extern(sqrt) func -> This
cbrt: extern(cbrt) func -> This
abs: extern(fabs) func -> This
pow: extern(pow) func (This) -> This
exp: extern(exp) func -> This
log: extern(log) func -> This
log10: extern(log10) func -> This
mod: extern(fmod) func (This) -> This
round: extern(round) func -> This
roundLong: extern(lround) func -> Long
roundLLong: extern(llround) func -> LLong
ceil: extern(ceil) func -> This
floor: extern(floor) func -> This
truncate: extern(trunc) func -> This
}
extend Float {
cos: extern(cosf) func -> This
sin: extern(sinf) func -> This
tan: extern(tanf) func -> This
acos: extern(acosf) func -> This
asin: extern(asinf) func -> This
atan: extern(atanf) func -> This
cosh: extern(coshf) func -> This
sinh: extern(sinhf) func -> This
tanh: extern(tanhf) func -> This
acosh: extern(acoshf) func -> This
asinh: extern(asinhf) func -> This
atanh: extern(atanhf) func -> This
atan2: extern(atan2f) func (This) -> This
sqrt: extern(sqrtf) func -> This
cbrt: extern(cbrtf) func -> This
abs: extern(fabsf) func -> This
pow: extern(powf) func (This) -> This
exp: extern(expf) func -> This
log: extern(logf) func -> This
log10: extern(log10f) func -> This
mod: extern(fmodf) func (This) -> This
round: extern(roundf) func -> This
roundLong: extern(lroundf) func -> Long
roundLLong: extern(llroundf) func -> LLong
ceil: extern(ceilf) func -> This
floor: extern(floorf) func -> This
truncate: extern(truncf) func -> This
}
extend LDouble {
cos: extern(cosl) func -> This
sin: extern(sinl) func -> This
tan: extern(tanl) func -> This
acos: extern(acosl) func -> This
asin: extern(asinl) func -> This
atan: extern(atanl) func -> This
cosh: extern(coshl) func -> This
sinh: extern(sinhl) func -> This
tanh: extern(tanhl) func -> This
acosh: extern(acoshl) func -> This
asinh: extern(asinhl) func -> This
atanh: extern(atanhl) func -> This
atan2: extern(atan2l) func (This) -> This
sqrt: extern(sqrtl) func -> This
cbrt: extern(cbrtl) func -> This
abs: extern(fabsl) func -> This
pow: extern(powl) func (This) -> This
exp: extern(expl) func -> This
log: extern(logl) func -> This
log10: extern(log10l) func -> This
mod: extern(fmodl) func (This) -> This
round: extern(roundl) func -> This
roundLong: extern(lroundl) func -> Long
roundLLong: extern(llroundl) func -> LLong
ceil: extern(ceill) func -> This
floor: extern(floorl) func -> This
truncate: extern(truncl) func -> This
}