Mercurial > repos > rhope
annotate number.c @ 29:3cc5e4a42344
Missed registration for *@Real Number in previous commit
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 27 Jun 2009 01:50:33 -0400 |
parents | 94c885692eb5 |
children | 429b5f441381 |
rev | line source |
---|---|
3
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
1 #include <math.h> |
0 | 2 #include <stdlib.h> |
3 #include "datum.h" | |
4 #include "structs.h" | |
5 #ifdef SEGA | |
6 long atol(const char * string) | |
7 { | |
8 int i = 0; | |
9 BOOL neg_flag = FALSE; | |
10 long value = 0.0; | |
11 while(string[i] != '\0') | |
12 { | |
13 if(string[i] >= '0' && string[i] <= '9') | |
14 { | |
15 value *= 10; | |
16 value += string[i] - '0'; | |
17 } | |
18 else if(string[i] == '-') | |
19 neg_flag = TRUE; | |
20 else if(string[i] != ' ' && string[i] != '\n' && string[i] != '\r' && string[i] != '\t') | |
21 { | |
22 break; | |
23 } | |
24 ++i; | |
25 } | |
26 if(neg_flag) | |
27 value = 0-value; | |
28 return value; | |
29 } | |
30 #endif | |
31 | |
32 int vis_stringtoint(datum ** inputlist, queue_entry * worker_entry) | |
33 { | |
34 datum * output; | |
35 int result = atol(inputlist[0]->c.generic.data); | |
36 VIS_EnterCriticalSection(inputlist[0]->lock); | |
37 if(inputlist[0]->ref_count == 1) | |
38 { | |
39 VIS_LeaveCriticalSection(inputlist[0]->lock); | |
40 VIS_FREE(inputlist[0]->c.generic.data, "<String@Whole Number, Freeing string for reuse as integer object"); | |
41 inputlist[0]->company = worker_entry->instance->def->program->companylist + BUILTIN_TYPE_WHOLE; | |
42 inputlist[0]->union_type = 2; | |
43 } | |
44 else | |
45 { | |
46 VIS_LeaveCriticalSection(inputlist[0]->lock); | |
47 release_ref(inputlist[0]); | |
48 inputlist[0] = new_datum(BUILTIN_TYPE_WHOLE, 2, 0, worker_entry->instance->def->program); | |
49 } | |
50 inputlist[0]->c.integers.num_a = result; | |
51 return 0; | |
52 } | |
53 | |
54 int vis_whole_fromhex(datum ** inputlist, queue_entry * worker_entry) | |
55 { | |
56 int i; | |
57 int result = 0; | |
58 char * data = inputlist[0]->c.generic.data; | |
59 for(i = 0; i < inputlist[0]->c.generic.len-1; ++i) | |
60 { | |
61 result <<= 4; | |
62 if(data[i] >= '0' && data[i] <= '9') | |
63 result |= data[i] - '0'; | |
64 else if(data[i] >= 'A' && data[i] <= 'F') | |
65 result |= data[i] - 'A' + 0xA; | |
66 else if(data[i] >= 'a' && data[i] <= 'f') | |
67 result |= data[i] - 'a' + 0xA; | |
68 } | |
69 release_ref(inputlist[0]); | |
70 inputlist[0] = new_datum(BUILTIN_TYPE_WHOLE, 2, 0, worker_entry->instance->def->program); | |
71 inputlist[0]->c.integers.num_a = result; | |
72 return 0; | |
73 } | |
74 | |
75 int vis_whole_add(datum ** inputlist, queue_entry * worker_entry) | |
76 { | |
77 datum * output; | |
78 int ref_count; | |
79 //VIS_PROFILE_START(PROF_ADDWHOLE); | |
80 VIS_EnterCriticalSection(inputlist[0]->lock); | |
81 ref_count = inputlist[0]->ref_count; | |
82 VIS_LeaveCriticalSection(inputlist[0]->lock); | |
83 if(ref_count == 1) | |
84 output = inputlist[0]; | |
85 else | |
86 { | |
87 VIS_EnterCriticalSection(inputlist[1]->lock); | |
88 ref_count = inputlist[1]->ref_count; | |
89 VIS_LeaveCriticalSection(inputlist[1]->lock); | |
90 if(ref_count == 1) | |
91 output = inputlist[1]; | |
92 else | |
93 output = new_datum(BUILTIN_TYPE_WHOLE, 2, 0, worker_entry->instance->def->program); | |
94 } | |
95 | |
96 output->c.integers.num_a = inputlist[0]->c.integers.num_a + inputlist[1]->c.integers.num_a; | |
97 if(output == inputlist[0]) | |
98 release_ref(inputlist[1]); | |
99 else if(output == inputlist[1]) | |
100 release_ref(inputlist[0]); | |
101 else | |
102 { | |
103 release_ref(inputlist[0]); | |
104 release_ref(inputlist[1]); | |
105 } | |
106 inputlist[0] = output; | |
107 //VIS_PROFILE_END(PROF_ADDWHOLE); | |
108 return 0; | |
109 } | |
110 | |
111 int vis_whole_subtract(datum ** inputlist, queue_entry * worker_entry) | |
112 { | |
113 datum * output; | |
114 output = new_datum(BUILTIN_TYPE_WHOLE, 2, 0, worker_entry->instance->def->program); | |
115 output->c.integers.num_a = inputlist[0]->c.integers.num_a - inputlist[1]->c.integers.num_a; | |
116 release_ref(inputlist[0]); | |
117 release_ref(inputlist[1]); | |
118 inputlist[0] = output; | |
119 return 0; | |
120 } | |
121 | |
122 int vis_whole_mult(datum ** inputlist, queue_entry * worker_entry) | |
123 { | |
124 inputlist[0] = copy_datum(inputlist[0], 0); | |
125 inputlist[0]->c.integers.num_a *= inputlist[1]->c.integers.num_a; | |
126 release_ref(inputlist[1]); | |
127 return 0; | |
128 } | |
129 | |
130 int vis_whole_div(datum ** inputlist, queue_entry * worker_entry) | |
131 { | |
132 inputlist[0] = copy_datum(inputlist[0], 0); | |
133 inputlist[0]->c.integers.num_a /= inputlist[1]->c.integers.num_a; | |
134 release_ref(inputlist[1]); | |
135 return 0; | |
136 } | |
137 | |
138 int vis_wholeequal(datum ** inputlist, queue_entry * worker_entry) | |
139 { | |
140 datum * output; | |
141 //VIS_PROFILE_START(PROF_EQUALWHOLE); | |
142 output = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
143 datum_set_yesno(output, inputlist[0]->c.integers.num_a == inputlist[1]->c.integers.num_a); | |
144 release_ref(inputlist[0]); | |
145 release_ref(inputlist[1]); | |
146 //VIS_PROFILE_END(PROF_EQUALWHOLE); | |
147 inputlist[0] = output; | |
148 return 0; | |
149 } | |
150 | |
151 int vis_whole_or(datum ** inputlist, queue_entry * worker_entry) | |
152 { | |
153 inputlist[0] = copy_datum(inputlist[0], 0); | |
154 inputlist[0]->c.integers.num_a |= inputlist[1]->c.integers.num_a; | |
155 release_ref(inputlist[1]); | |
156 return 0; | |
157 } | |
158 | |
159 int vis_whole_and(datum ** inputlist, queue_entry * worker_entry) | |
160 { | |
161 inputlist[0] = copy_datum(inputlist[0], 0); | |
162 inputlist[0]->c.integers.num_a &= inputlist[1]->c.integers.num_a; | |
163 release_ref(inputlist[1]); | |
164 return 0; | |
165 } | |
166 | |
167 int vis_whole_lsh(datum ** inputlist, queue_entry * worker_entry) | |
168 { | |
169 inputlist[0] = copy_datum(inputlist[0], 0); | |
170 inputlist[0]->c.integers.num_a <<= inputlist[1]->c.integers.num_a; | |
171 release_ref(inputlist[1]); | |
172 return 0; | |
173 } | |
174 | |
175 int vis_whole_rsh(datum ** inputlist, queue_entry * worker_entry) | |
176 { | |
177 inputlist[0] = copy_datum(inputlist[0], 0); | |
178 inputlist[0]->c.integers.num_a >>= inputlist[1]->c.integers.num_a; | |
179 release_ref(inputlist[1]); | |
180 return 0; | |
181 } | |
182 | |
183 | |
184 int vis_greaterint(datum ** inputlist, queue_entry * worker_entry) | |
185 { | |
186 int result; | |
187 if(inputlist[0]->c.integers.num_a > inputlist[1]->c.integers.num_a) | |
188 result = 1; | |
189 else | |
190 result = 0; | |
191 | |
192 release_ref(inputlist[0]); | |
193 release_ref(inputlist[1]); | |
194 inputlist[0] = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
195 datum_set_yesno(inputlist[0], result); | |
196 return 0; | |
197 } | |
198 | |
199 int vis_lesserint(datum ** inputlist, queue_entry * worker_entry) | |
200 { | |
201 int result, ref_count; | |
202 //VIS_PROFILE_START(PROF_LESSERWHOLE); | |
203 if(inputlist[0]->c.integers.num_a < inputlist[1]->c.integers.num_a) | |
204 result = 1; | |
205 else | |
206 result = 0; | |
207 VIS_EnterCriticalSection(inputlist[0]->lock); | |
208 ref_count = inputlist[0]->ref_count; | |
209 VIS_LeaveCriticalSection(inputlist[0]->lock); | |
210 if(ref_count == 1) | |
211 { | |
212 release_ref(inputlist[1]); | |
213 inputlist[0]->company = worker_entry->instance->def->program->companylist + BUILTIN_TYPE_YESNO; | |
214 inputlist[0]->union_type = 2; | |
215 } | |
216 else | |
217 { | |
218 VIS_EnterCriticalSection(inputlist[1]->lock); | |
219 ref_count = inputlist[1]->ref_count; | |
220 VIS_LeaveCriticalSection(inputlist[1]->lock); | |
221 if(ref_count == 1) | |
222 { | |
223 release_ref(inputlist[0]); | |
224 inputlist[0] = inputlist[1]; | |
225 inputlist[0]->company = worker_entry->instance->def->program->companylist + BUILTIN_TYPE_YESNO; | |
226 inputlist[0]->union_type = 2; | |
227 } | |
228 else | |
229 { | |
230 release_ref(inputlist[0]); | |
231 release_ref(inputlist[1]); | |
232 inputlist[0] = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
233 } | |
234 } | |
235 //datum_set_yesno(inputlist[0], result); | |
236 inputlist[0]->c.integers.num_a = result; | |
237 //VIS_PROFILE_END(PROF_LESSERWHOLE); | |
238 return 0; | |
239 } | |
240 #ifndef WIN32 | |
241 double atof(const char * string) | |
242 { | |
243 int i = 0; | |
244 BOOL neg_flag = FALSE; | |
245 double value = 0.0; | |
246 double divisor = 10; | |
247 while(string[i] != '\0' && string[i] != '.') | |
248 { | |
249 if(string[i] >= '0' && string[i] <= '9') | |
250 { | |
251 value *= 10.0; | |
252 value += string[i] - '0'; | |
253 } | |
254 else if(string[i] == '-') | |
255 neg_flag = TRUE; | |
256 else if(string[i] != ' ' && string[i] != '\n' && string[i] != '\r' && string[i] != '\t') | |
257 return value; | |
258 ++i; | |
259 } | |
260 if(string[i] != '\0') | |
261 { | |
262 ++i; | |
3
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
263 while(string[i] != '\0' && string[i] >= '0' && string[i] <= '9') |
0 | 264 { |
265 value += ((double)(string[i] - '0'))/divisor; | |
266 divisor *= 10; | |
3
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
267 ++i; |
0 | 268 } |
269 } | |
3
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
270 if(neg_flag) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
271 value = 0.0-value; |
0 | 272 return value; |
273 } | |
274 #endif | |
275 | |
276 int vis_stringtoreal(datum ** inputlist, queue_entry * worker_entry) | |
277 { | |
278 datum * output; | |
279 output = new_datum(BUILTIN_TYPE_REAL, 3, 0, worker_entry->instance->def->program); | |
280 output->c.real = atof(inputlist[0]->c.generic.data); | |
281 release_ref(inputlist[0]); | |
282 inputlist[0] = output; | |
283 return 0; | |
284 } | |
285 | |
286 int vis_real_add(datum ** inputlist, queue_entry * worker_entry) | |
287 { | |
288 datum * output; | |
289 output = new_datum(BUILTIN_TYPE_REAL, 3, 0, worker_entry->instance->def->program); | |
290 output->c.real = inputlist[0]->c.real + inputlist[1]->c.real; | |
291 release_ref(inputlist[0]); | |
292 release_ref(inputlist[1]); | |
293 inputlist[0] = output; | |
294 return 0; | |
295 } | |
296 | |
297 int vis_real_subtract(datum ** inputlist, queue_entry * worker_entry) | |
298 { | |
299 datum * output; | |
300 output = new_datum(BUILTIN_TYPE_REAL, 3, 0, worker_entry->instance->def->program); | |
301 output->c.real = inputlist[0]->c.real - inputlist[1]->c.real; | |
302 release_ref(inputlist[0]); | |
303 release_ref(inputlist[1]); | |
304 inputlist[0] = output; | |
305 return 0; | |
306 } | |
307 | |
308 | |
309 int vis_realequal(datum ** inputlist, queue_entry * worker_entry) | |
310 { | |
311 datum * output = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
312 datum_set_yesno(output, inputlist[0]->c.real == inputlist[1]->c.real); | |
313 release_ref(inputlist[0]); | |
314 release_ref(inputlist[1]); | |
315 inputlist[0] = output; | |
316 return 0; | |
317 } | |
318 | |
319 int vis_greaterreal(datum ** inputlist, queue_entry * worker_entry) | |
320 { | |
321 int result; | |
322 if(inputlist[0]->c.real > inputlist[1]->c.real) | |
323 result = 1; | |
324 else | |
325 result = 0; | |
326 release_ref(inputlist[0]); | |
327 release_ref(inputlist[1]); | |
328 inputlist[0] = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
329 datum_set_yesno(inputlist[0], result); | |
330 return 0; | |
331 } | |
332 | |
333 int vis_lesserreal(datum ** inputlist, queue_entry * worker_entry) | |
334 { | |
335 int result; | |
336 if(inputlist[0]->c.real < inputlist[1]->c.real) | |
337 result = 1; | |
338 else | |
339 result = 0; | |
340 release_ref(inputlist[0]); | |
341 release_ref(inputlist[1]); | |
342 inputlist[0] = new_datum(BUILTIN_TYPE_YESNO, 2, 0, worker_entry->instance->def->program); | |
343 datum_set_yesno(inputlist[0], result); | |
344 return 0; | |
345 } | |
346 | |
347 int vis_real_div(datum ** inputlist, queue_entry * worker_entry) | |
348 { | |
349 inputlist[0] = copy_datum(inputlist[0], 0); | |
350 inputlist[0]->c.real /= inputlist[1]->c.real; | |
351 release_ref(inputlist[1]); | |
352 return 0; | |
353 } | |
354 | |
3
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
355 int vis_real_mult(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
356 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
357 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
358 inputlist[0]->c.real *= inputlist[1]->c.real; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
359 release_ref(inputlist[1]); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
360 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
361 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
362 #define PI 3.14159265 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
363 int vis_real_cos(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
364 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
365 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
366 inputlist[0]->c.real = cos(inputlist[0]->c.real * PI/180.0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
367 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
368 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
369 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
370 int vis_real_sin(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
371 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
372 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
373 inputlist[0]->c.real = sin(inputlist[0]->c.real * PI/180.0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
374 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
375 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
376 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
377 int vis_real_tan(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
378 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
379 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
380 inputlist[0]->c.real = tan(inputlist[0]->c.real * PI/180.0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
381 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
382 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
383 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
384 int vis_real_arccos(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
385 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
386 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
387 inputlist[0]->c.real = acos(inputlist[0]->c.real)*180.0/PI; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
388 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
389 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
390 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
391 int vis_real_arcsin(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
392 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
393 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
394 inputlist[0]->c.real = asin(inputlist[0]->c.real)*180.0/PI; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
395 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
396 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
397 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
398 int vis_real_arctan(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
399 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
400 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
401 inputlist[0]->c.real = atan(inputlist[0]->c.real)*180.0/PI; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
402 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
403 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
404 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
405 int vis_real_exp(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
406 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
407 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
408 inputlist[0]->c.real = pow(inputlist[0]->c.real, inputlist[1]->c.real); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
409 release_ref(inputlist[1]); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
410 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
411 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
412 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
413 int vis_real_sqrt(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
414 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
415 inputlist[0] = copy_datum(inputlist[0], 0); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
416 inputlist[0]->c.real = sqrt(inputlist[0]->c.real); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
417 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
418 } |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
419 |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
420 int vis_whole_fromreal(datum ** inputlist, queue_entry * worker_entry) |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
421 { |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
422 datum * output = new_datum(BUILTIN_TYPE_WHOLE, 2, 0, worker_entry->instance->def->program); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
423 output->c.integers.num_a = inputlist[0]->c.real; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
424 release_ref(inputlist[0]); |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
425 inputlist[0] = output; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
426 return 0; |
94c885692eb5
Partial set of fixes and enhancements from Linux box
Mike Pavone <pavone@retrodev.com>
parents:
0
diff
changeset
|
427 } |