1 | [[tags: egg]] |
---|
2 | |
---|
3 | == err5rs-arithmetic |
---|
4 | |
---|
5 | [[toc:]] |
---|
6 | |
---|
7 | |
---|
8 | == Documentation |
---|
9 | |
---|
10 | ERR5RS arithmetic routines. |
---|
11 | |
---|
12 | See [[http://scheme-punks.cyber-rush.org/wiki/index.php?title=ERR5RS:SRFIs_and_Standard_Libraries|ERR5RS:SRFIs_and_Standard_Libraries]] |
---|
13 | |
---|
14 | Note that while this egg is named ''err5rs-arithmetic'' the actual extension is |
---|
15 | ''err5rs-arithmetic-fixnums'', ''err5rs-arithmetic-bitwise'' and ''err5rs-arithmetic-flonums''. |
---|
16 | |
---|
17 | |
---|
18 | === Fixnum Arithmetic |
---|
19 | |
---|
20 | ERR5RS fixnum functions. |
---|
21 | |
---|
22 | See [[http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-12.html#node_sec_11.2|Fixnums]] |
---|
23 | |
---|
24 | ==== representation-violation? |
---|
25 | |
---|
26 | <procedure>(representation-violation? OBJECT) => BOOLEAN</procedure> |
---|
27 | |
---|
28 | Is the {{OBJECT}} a representation error condition? |
---|
29 | |
---|
30 | ==== zero-division-violation? |
---|
31 | |
---|
32 | <procedure>(zero-division-violation? OBJECT) => BOOLEAN</procedure> |
---|
33 | |
---|
34 | Is the {{OBJECT}} a zero division attempt error condition? |
---|
35 | |
---|
36 | ==== fixnum-width |
---|
37 | |
---|
38 | <procedure>(fixnum-width) => FIXNUM</procedure> |
---|
39 | |
---|
40 | ==== least-fixnum |
---|
41 | |
---|
42 | <procedure>(least-fixnum) => FIXNUM</procedure> |
---|
43 | |
---|
44 | ==== greatest-fixnum |
---|
45 | |
---|
46 | <procedure>(greatest-fixnum) => FIXNUM</procedure> |
---|
47 | |
---|
48 | ==== fx=? |
---|
49 | |
---|
50 | <procedure>(fx=? FX...) => BOOLEAN</procedure> |
---|
51 | |
---|
52 | ==== fx<? |
---|
53 | |
---|
54 | <procedure>(fx<? FX...) => BOOLEAN</procedure> |
---|
55 | |
---|
56 | ==== fx>? |
---|
57 | |
---|
58 | <procedure>(fx>? FX...) => BOOLEAN</procedure> |
---|
59 | |
---|
60 | ==== fx<=? |
---|
61 | |
---|
62 | <procedure>(fx<=? FX...) => BOOLEAN</procedure> |
---|
63 | |
---|
64 | ==== fx>=? |
---|
65 | |
---|
66 | <procedure>(fx>=? FX...) => BOOLEAN</procedure> |
---|
67 | |
---|
68 | ==== fxzero? |
---|
69 | |
---|
70 | <procedure>(fxzero? FX) => BOOLEAN</procedure> |
---|
71 | |
---|
72 | ==== fxpositive? |
---|
73 | |
---|
74 | <procedure>(fxpositive? FX) => BOOLEAN</procedure> |
---|
75 | |
---|
76 | ==== fxnegative? |
---|
77 | |
---|
78 | <procedure>(fxnegative? FX) => BOOLEAN</procedure> |
---|
79 | |
---|
80 | ==== fxodd? |
---|
81 | |
---|
82 | <procedure>(fxodd? FX) => BOOLEAN</procedure> |
---|
83 | |
---|
84 | ==== fxeven? |
---|
85 | |
---|
86 | <procedure>(fxeven? FX) => BOOLEAN</procedure> |
---|
87 | |
---|
88 | ==== fxmax |
---|
89 | |
---|
90 | <procedure>(fxmax FX...) => FIXNUM</procedure> |
---|
91 | |
---|
92 | ==== fxmin |
---|
93 | |
---|
94 | <procedure>(fxmin FX...) => FIXNUM</procedure> |
---|
95 | |
---|
96 | ==== fxmax-and-min |
---|
97 | |
---|
98 | <procedure>(fxmax-and-min FX...) => FIXNUM+FIXNUM</procedure> |
---|
99 | |
---|
100 | ==== fxmodulo |
---|
101 | |
---|
102 | <procedure>(fxmodulo FXN FXD) => FIXNUM</procedure> |
---|
103 | |
---|
104 | ==== fxdiv |
---|
105 | |
---|
106 | <procedure>(fxdiv FXN FXD) => FIXNUM</procedure> |
---|
107 | |
---|
108 | ==== fxdiv-and-mod |
---|
109 | |
---|
110 | <procedure>(fxdiv-and-mod FXN FXD) => FIXNUM+FIXNUM</procedure> |
---|
111 | |
---|
112 | ==== fxdiv0 |
---|
113 | |
---|
114 | <procedure>(fxdiv0 FXN FXD) => FIXNUM</procedure> |
---|
115 | |
---|
116 | ==== fxmod0 |
---|
117 | |
---|
118 | <procedure>(fxmod0 FXN FXD) => FIXNUM</procedure> |
---|
119 | |
---|
120 | ==== fxdiv0-and-mod0 |
---|
121 | |
---|
122 | <procedure>(fxdiv0-and-mod0 FXN FXD) => FIXNUM+FIXNUM</procedure> |
---|
123 | |
---|
124 | ==== fx*/carry |
---|
125 | |
---|
126 | <procedure>(fx*/carry FX1 FX2 FX3) => FIXNUM+FIXNUM</procedure> |
---|
127 | |
---|
128 | ==== fx+/carry |
---|
129 | |
---|
130 | <procedure>(fx+/carry FX1 FX2 FX3) => FIXNUM+FIXNUM</procedure> |
---|
131 | |
---|
132 | ==== fx-/carry |
---|
133 | |
---|
134 | <procedure>(fx-/carry FX1 FX2 FX3) => FIXNUM+FIXNUM</procedure> |
---|
135 | |
---|
136 | ==== fxarithmetic-shift |
---|
137 | |
---|
138 | <procedure>(fxarithmetic-shift FX DIRECTIONAL-AMOUNT) => FIXNUM</procedure> |
---|
139 | |
---|
140 | ==== fxarithmetic-shift-left |
---|
141 | |
---|
142 | <procedure>(fxarithmetic-shift-left FX AMOUNT) => FIXNUM</procedure> |
---|
143 | |
---|
144 | ==== fxarithmetic-shift-right |
---|
145 | |
---|
146 | <procedure>(fxarithmetic-shift-right FX AMOUNT) => FIXNUM</procedure> |
---|
147 | |
---|
148 | ==== fx+ |
---|
149 | |
---|
150 | <procedure>(fx+ FX FX2) => FIXNUM</procedure> |
---|
151 | |
---|
152 | ==== fx- |
---|
153 | |
---|
154 | <procedure>(fx- FX [FX2]) => FIXNUM</procedure> |
---|
155 | |
---|
156 | ==== fx* |
---|
157 | |
---|
158 | <procedure>(fx* FX FX2) => FIXNUM</procedure> |
---|
159 | |
---|
160 | ==== fxand |
---|
161 | |
---|
162 | <procedure>(fxand FX...) => FIXNUM</procedure> |
---|
163 | |
---|
164 | ==== fxior |
---|
165 | |
---|
166 | <procedure>(fxior FX...) => FIXNUM</procedure> |
---|
167 | |
---|
168 | ==== fxxor |
---|
169 | |
---|
170 | <procedure>(fxxor FX...) => FIXNUM</procedure> |
---|
171 | |
---|
172 | ==== fxif |
---|
173 | |
---|
174 | <procedure>(fxif MASK TRUE FALSE) => FIXNUM</procedure> |
---|
175 | |
---|
176 | ==== fxbit-count |
---|
177 | |
---|
178 | <procedure>(fxbit-count FX) => FIXNUM</procedure> |
---|
179 | |
---|
180 | ==== fxlength |
---|
181 | |
---|
182 | <procedure>(fxlength FX) => FIXNUM</procedure> |
---|
183 | |
---|
184 | ==== fxfirst-bit-set |
---|
185 | |
---|
186 | <procedure>(fxfirst-bit-set FX) => FIXNUM</procedure> |
---|
187 | |
---|
188 | ==== fxbit-set? |
---|
189 | |
---|
190 | <procedure>(fxbit-set? FX INDEX) => BOOLEAN</procedure> |
---|
191 | |
---|
192 | ==== fxcopy-bit |
---|
193 | |
---|
194 | <procedure>(fxcopy-bit FX INDEX BIT) => FIXNUM</procedure> |
---|
195 | |
---|
196 | ==== fxbit-field |
---|
197 | |
---|
198 | <procedure>(fxbit-field FX START END) => FIXNUM</procedure> |
---|
199 | |
---|
200 | ==== fxcopy-bit-field |
---|
201 | |
---|
202 | <procedure>(fxcopy-bit-field FX-TO START END FX-FROM) => FIXNUM</procedure> |
---|
203 | |
---|
204 | ==== fxrotate-bit-field |
---|
205 | |
---|
206 | <procedure>(fxrotate-bit-field FX START END COUNT) => FIXNUM</procedure> |
---|
207 | |
---|
208 | ==== fxreverse-bit-field |
---|
209 | |
---|
210 | <procedure>(fxreverse-bit-field FX START END) => FIXNUM</procedure> |
---|
211 | |
---|
212 | ==== Extras |
---|
213 | |
---|
214 | (All `-fx...' identifiers are reserved.) |
---|
215 | |
---|
216 | ==== fx<>? |
---|
217 | |
---|
218 | <procedure>(fx<>? FX1 FX2) => BOOLEAN</procedure> |
---|
219 | |
---|
220 | ==== fxcompare |
---|
221 | |
---|
222 | <procedure>(fxcompare FX1 FX2) => BOOLEAN</procedure> |
---|
223 | |
---|
224 | ==== fxabs |
---|
225 | |
---|
226 | <procedure>(fxabs FX) => FIXNUM</procedure> |
---|
227 | |
---|
228 | ===== fxnegate |
---|
229 | |
---|
230 | <procedure>(fxnegate FX) => FIXNUM</procedure> |
---|
231 | |
---|
232 | ==== fxadd1 |
---|
233 | |
---|
234 | <procedure>(fxadd1 FX) => FIXNUM</procedure> |
---|
235 | |
---|
236 | ==== fxsub1 |
---|
237 | |
---|
238 | <procedure>(fxsub1 FX) => FIXNUM</procedure> |
---|
239 | |
---|
240 | ===== fx/ |
---|
241 | |
---|
242 | <procedure>(fx/ FX1 FX2) => FIXNUM</procedure> |
---|
243 | |
---|
244 | ==== fxquotient |
---|
245 | |
---|
246 | <procedure>(fxquotient FXN FXD) => FIXNUM</procedure> |
---|
247 | |
---|
248 | ==== fxremainder |
---|
249 | |
---|
250 | <procedure>(fxremainder FXN FXD) => FIXNUM</procedure> |
---|
251 | |
---|
252 | ===== fxpow2log2 |
---|
253 | |
---|
254 | <procedure>(fxpow2log2 FX) => FIXNUM</procedure> |
---|
255 | |
---|
256 | ===== fxif-not |
---|
257 | |
---|
258 | <procedure>(fxif-not MASK TRUE FALSE) => FIXNUM</procedure> |
---|
259 | |
---|
260 | ==== fxlast-bit-set |
---|
261 | |
---|
262 | <procedure>(fxlast-bit-set FX) => FIXNUM</procedure> |
---|
263 | |
---|
264 | ===== fixnum->string |
---|
265 | |
---|
266 | <procedure>(fixnum->string FX [RADIX]) => STRING</procedure> |
---|
267 | |
---|
268 | ===== $fx=? |
---|
269 | |
---|
270 | <macro>($fx=? FX [FX1...]) => BOOLEAN</macro> |
---|
271 | |
---|
272 | ===== $fx<? |
---|
273 | |
---|
274 | <macro>($fx<? FX [FX1...]) => BOOLEAN</macro> |
---|
275 | |
---|
276 | ===== $fx>? |
---|
277 | |
---|
278 | <macro>($fx>? FX [FX1...]) => BOOLEAN</macro> |
---|
279 | |
---|
280 | ===== $fx<=? |
---|
281 | |
---|
282 | <macro>($fx<=? FX [FX1...]) => BOOLEAN</macro> |
---|
283 | |
---|
284 | ===== $fx>=? |
---|
285 | |
---|
286 | <macro>($fx>=? FX [FX1...]) => BOOLEAN</macro> |
---|
287 | |
---|
288 | ===== $fxmax |
---|
289 | |
---|
290 | <macro>($fxmax FX [FX1...]) => FIXNUM</macro> |
---|
291 | |
---|
292 | ===== $fxmin |
---|
293 | |
---|
294 | <macro>($fxmin FX [FX1...]) => FIXNUM</macro> |
---|
295 | |
---|
296 | ===== $fxand |
---|
297 | |
---|
298 | <macro>($fxand FX [FX1...]) => FIXNUM</macro> |
---|
299 | |
---|
300 | ===== $fxior |
---|
301 | |
---|
302 | <macro>($fxior FX [FX1...]) => FIXNUM</macro> |
---|
303 | |
---|
304 | ===== $fxxor |
---|
305 | |
---|
306 | <macro>($fxxor FX [FX1...]) => FIXNUM</macro> |
---|
307 | |
---|
308 | ===== $fx+ |
---|
309 | |
---|
310 | <macro>($fx+ FX [FX1...]) => FIXNUM</macro> |
---|
311 | |
---|
312 | ===== $fx- |
---|
313 | |
---|
314 | <macro>($fx- FX [FX1...]) => FIXNUM</macro> |
---|
315 | |
---|
316 | ===== $fx* |
---|
317 | |
---|
318 | <macro>($fx* FX [FX1...]) => FIXNUM</macro> |
---|
319 | |
---|
320 | ===== $fx/ |
---|
321 | |
---|
322 | <macro>($fx/ FX [FX1...]) => FIXNUM</macro> |
---|
323 | |
---|
324 | ==== Chicken Originals |
---|
325 | |
---|
326 | ===== chicken:fxmax |
---|
327 | ===== chicken:fxmin |
---|
328 | ===== chicken:fxnot |
---|
329 | ===== chicken:fxand |
---|
330 | ===== chicken:fxior |
---|
331 | ===== chicken:fxxor |
---|
332 | ===== chicken:fx+ |
---|
333 | ===== chicken:fx- |
---|
334 | ===== chicken:fx* |
---|
335 | ===== chicken:fx/ |
---|
336 | ===== chicken:fxmod |
---|
337 | |
---|
338 | |
---|
339 | === Flonum Arithmetic |
---|
340 | |
---|
341 | ERR5RS flonum functions. |
---|
342 | |
---|
343 | See [[http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-12.html#node_sec_11.3|Flonums]] |
---|
344 | |
---|
345 | ==== real->flonum |
---|
346 | |
---|
347 | <procedure>(real->flonum NUMBER) => FLONUM</procedure> |
---|
348 | |
---|
349 | {{NUMBER}} may only be a {{fixnum}} or {{flonum}}. |
---|
350 | |
---|
351 | ==== fixnum->flonum |
---|
352 | |
---|
353 | <procedure>(fixnum->flonum FX) => FLONUM</procedure> |
---|
354 | |
---|
355 | ==== fl=? |
---|
356 | |
---|
357 | <procedure>(fl=? FP...) => BOOLEAN</procedure> |
---|
358 | |
---|
359 | ==== fl<? |
---|
360 | |
---|
361 | <procedure>(fl<? FP...) => BOOLEAN</procedure> |
---|
362 | |
---|
363 | ==== fl>? |
---|
364 | |
---|
365 | <procedure>(fl>? FP...) => BOOLEAN</procedure> |
---|
366 | |
---|
367 | ==== fl<=? |
---|
368 | |
---|
369 | <procedure>(fl<=? FP...) => BOOLEAN</procedure> |
---|
370 | |
---|
371 | ==== fl>=? |
---|
372 | |
---|
373 | <procedure>(fl>=? FP...) => BOOLEAN</procedure> |
---|
374 | |
---|
375 | ==== flinteger? |
---|
376 | |
---|
377 | <procedure>(flinteger? FP) => BOOLEAN</procedure> |
---|
378 | |
---|
379 | ==== flzero? |
---|
380 | |
---|
381 | <procedure>(flzero? FP) => BOOLEAN</procedure> |
---|
382 | |
---|
383 | ==== flpositive? |
---|
384 | |
---|
385 | <procedure>(flpositive? FP) => BOOLEAN</procedure> |
---|
386 | |
---|
387 | ==== flnegative? |
---|
388 | |
---|
389 | <procedure>(flnegative? FP) => BOOLEAN</procedure> |
---|
390 | |
---|
391 | ==== flodd? |
---|
392 | |
---|
393 | <procedure>(flodd? FP) => BOOLEAN</procedure> |
---|
394 | |
---|
395 | ==== fleven? |
---|
396 | |
---|
397 | <procedure>(fleven? FP) => BOOLEAN</procedure> |
---|
398 | |
---|
399 | ==== flfinite? |
---|
400 | |
---|
401 | <procedure>(flfinite? FP) => BOOLEAN</procedure> |
---|
402 | |
---|
403 | ==== flinfinite? |
---|
404 | |
---|
405 | <procedure>(flinfinite? FP) => BOOLEAN</procedure> |
---|
406 | |
---|
407 | ==== flnan? |
---|
408 | |
---|
409 | <procedure>(flnan? FP) => BOOLEAN</procedure> |
---|
410 | |
---|
411 | ==== fl+ |
---|
412 | |
---|
413 | <procedure>(fl+ FP...) => FLONUM</procedure> |
---|
414 | |
---|
415 | ==== fl* |
---|
416 | |
---|
417 | <procedure>(fl* FP...) => FLONUM</procedure> |
---|
418 | |
---|
419 | ==== fl- |
---|
420 | |
---|
421 | <procedure>(fl- FP...) => FLONUM</procedure> |
---|
422 | |
---|
423 | ==== fl/ |
---|
424 | |
---|
425 | <procedure>(fl/ FP...) => FLONUM</procedure> |
---|
426 | |
---|
427 | ==== flmax |
---|
428 | |
---|
429 | <procedure>(flmax FP...) => FLONUM</procedure> |
---|
430 | |
---|
431 | ==== flmin |
---|
432 | |
---|
433 | <procedure>(flmin FP...) => FLONUM</procedure> |
---|
434 | |
---|
435 | ==== flmax-and-min |
---|
436 | |
---|
437 | <procedure>(flmax-and-min FP...) => FLONUM</procedure> |
---|
438 | |
---|
439 | ==== flabs |
---|
440 | |
---|
441 | <procedure>(flabs FP) => FLONUM</procedure> |
---|
442 | |
---|
443 | ==== fltruncate |
---|
444 | |
---|
445 | <procedure>(fltruncate FP) => FLONUM</procedure> |
---|
446 | |
---|
447 | ==== flfloor |
---|
448 | |
---|
449 | <procedure>(flfloor FP) => FLONUM</procedure> |
---|
450 | |
---|
451 | ==== flceiling |
---|
452 | |
---|
453 | <procedure>(flceiling FP) => FLONUM</procedure> |
---|
454 | |
---|
455 | ==== flround |
---|
456 | |
---|
457 | <procedure>(flround FP) => FLONUM</procedure> |
---|
458 | |
---|
459 | ==== fldiv |
---|
460 | |
---|
461 | <procedure>(fldiv FLN FLD) => FLONUM</procedure> |
---|
462 | |
---|
463 | ==== flmod |
---|
464 | |
---|
465 | <procedure>(flmod FLN FLD) => FLONUM</procedure> |
---|
466 | |
---|
467 | ==== fldiv-and-mod |
---|
468 | |
---|
469 | <procedure>(fldiv-and-mod FLN FLD) => FLONUM</procedure> |
---|
470 | |
---|
471 | ==== fldiv0 |
---|
472 | |
---|
473 | <procedure>(fldiv0 FLN FLD) => FLONUM</procedure> |
---|
474 | |
---|
475 | ==== flmod0 |
---|
476 | |
---|
477 | <procedure>(flmod0 FLN FLD) => FLONUM</procedure> |
---|
478 | |
---|
479 | ==== fldiv0-and-mod0 |
---|
480 | |
---|
481 | <procedure>(fldiv0-and-mod0 FLN FLD) => FLONUM</procedure> |
---|
482 | |
---|
483 | ==== flexp |
---|
484 | |
---|
485 | <procedure>(flexp FP) => FLONUM</procedure> |
---|
486 | |
---|
487 | ==== fllog |
---|
488 | |
---|
489 | <procedure>(fllog FP [BASE]) => FLONUM</procedure> |
---|
490 | |
---|
491 | ==== flsin |
---|
492 | |
---|
493 | <procedure>(flsin FP) => FLONUM</procedure> |
---|
494 | |
---|
495 | ==== flcos |
---|
496 | |
---|
497 | <procedure>(flcos FP) => FLONUM</procedure> |
---|
498 | |
---|
499 | ==== fltan |
---|
500 | |
---|
501 | <procedure>(fltan FP) => FLONUM</procedure> |
---|
502 | |
---|
503 | ==== flasin |
---|
504 | |
---|
505 | <procedure>(flasin FP) => FLONUM</procedure> |
---|
506 | |
---|
507 | ==== flacos |
---|
508 | |
---|
509 | <procedure>(flacos FP) => FLONUM</procedure> |
---|
510 | |
---|
511 | ==== flatan |
---|
512 | |
---|
513 | <procedure>(flatan FP [FP2]) => FLONUM</procedure> |
---|
514 | |
---|
515 | ==== flsqrt |
---|
516 | |
---|
517 | <procedure>(flsqrt FP) => FLONUM</procedure> |
---|
518 | |
---|
519 | ==== flexpt |
---|
520 | |
---|
521 | <procedure>(flexpt FP EXP) => FLONUM</procedure> |
---|
522 | |
---|
523 | ==== flnumerator |
---|
524 | |
---|
525 | <procedure>(flnumerator FP) => FLONUM</procedure> |
---|
526 | |
---|
527 | ==== fldenominator |
---|
528 | |
---|
529 | <procedure>(fldenominator FP) => FLONUM</procedure> |
---|
530 | |
---|
531 | ==== Extras |
---|
532 | |
---|
533 | (All `-fl...' identifiers are reserved.) |
---|
534 | |
---|
535 | ==== fl<>? |
---|
536 | |
---|
537 | <procedure>(fl<>? FP1 FP2) => BOOLEAN</procedure> |
---|
538 | |
---|
539 | ==== flcompare |
---|
540 | |
---|
541 | <procedure>(flcompare FP1 FP2) => BOOLEAN</procedure> |
---|
542 | |
---|
543 | ==== flgcd |
---|
544 | |
---|
545 | <procedure>(flgcd FP1 FP2) => FLONUM</procedure> |
---|
546 | |
---|
547 | ==== fllcm |
---|
548 | |
---|
549 | <procedure>(fllcm FP1 FP2) => FLONUM</procedure> |
---|
550 | |
---|
551 | ==== flfraction |
---|
552 | |
---|
553 | <procedure>(flfraction FP) => FLONUM</procedure> |
---|
554 | |
---|
555 | ==== flonum->fraction |
---|
556 | |
---|
557 | <procedure>(flonum->fraction FP) => FLONUM+FLONUM</procedure> |
---|
558 | |
---|
559 | ===== flnegate |
---|
560 | |
---|
561 | <procedure>(flnegate FP) => FLONUM</procedure> |
---|
562 | |
---|
563 | ===== $fl=? |
---|
564 | |
---|
565 | <macro>($fl=? FP [FP1...]) => BOOLEAN</macro> |
---|
566 | |
---|
567 | ===== $fl<? |
---|
568 | |
---|
569 | <macro>($fl<? FP [FP1...]) => BOOLEAN</macro> |
---|
570 | |
---|
571 | ===== $fl>? |
---|
572 | |
---|
573 | <macro>($fl>? FP [FP1...]) => BOOLEAN</macro> |
---|
574 | |
---|
575 | ===== $fl<=? |
---|
576 | |
---|
577 | <macro>($fl<=? FP [FP1...]) => BOOLEAN</macro> |
---|
578 | |
---|
579 | ===== $fl>=? |
---|
580 | |
---|
581 | <macro>($fl>=? FP [FP1...]) => BOOLEAN</macro> |
---|
582 | |
---|
583 | ===== $flmax |
---|
584 | |
---|
585 | <macro>($flmax FP [FP1...]) => FLONUM</macro> |
---|
586 | |
---|
587 | ===== $flmin |
---|
588 | |
---|
589 | <macro>($flmin FP [FP1...]) => FLONUM</macro> |
---|
590 | |
---|
591 | ===== $fland |
---|
592 | |
---|
593 | <macro>($fland FP [FP1...]) => FLONUM</macro> |
---|
594 | |
---|
595 | ===== $flior |
---|
596 | |
---|
597 | <macro>($flior FP [FP1...]) => FLONUM</macro> |
---|
598 | |
---|
599 | ===== $flxor |
---|
600 | |
---|
601 | <macro>($flxor FP [FP1...]) => FLONUM</macro> |
---|
602 | |
---|
603 | ===== $fl+ |
---|
604 | |
---|
605 | <macro>($fl+ FP [FP1...]) => FLONUM</macro> |
---|
606 | |
---|
607 | ===== $fl- |
---|
608 | |
---|
609 | <macro>($fl- FP [FP1...]) => FLONUM</macro> |
---|
610 | |
---|
611 | ===== $fl* |
---|
612 | |
---|
613 | <macro>($fl* FP [FP1...]) => FLONUM</macro> |
---|
614 | |
---|
615 | ===== $fl/ |
---|
616 | |
---|
617 | <macro>($fl/ FP [FP1...]) => FLONUM</macro> |
---|
618 | |
---|
619 | |
---|
620 | === Bitwise Arithmetic |
---|
621 | |
---|
622 | ERR5RS bitwise functions. |
---|
623 | |
---|
624 | See [[http://www.r6rs.org/final/html/r6rs-lib/r6rs-lib-Z-H-12.html#node_sec_11.1|Exact bitwise arithmetic]] |
---|
625 | |
---|
626 | ==== bitwise-if |
---|
627 | |
---|
628 | <procedure>(bitwise-if MASK TRUE FALSE) => INTEGER</procedure> |
---|
629 | |
---|
630 | ==== bitwise-test? |
---|
631 | |
---|
632 | <procedure>(bitwise-test? VALUE1 VALUE2) => BOOLEAN</procedure> |
---|
633 | |
---|
634 | ==== bitwise-bit-count |
---|
635 | |
---|
636 | <procedure>(bitwise-bit-count VALUE) => INTEGER</procedure> |
---|
637 | |
---|
638 | ==== bitwise-length |
---|
639 | |
---|
640 | <procedure>(bitwise-length VALUE) => INTEGER</procedure> |
---|
641 | |
---|
642 | ==== bitwise-first-bit-set |
---|
643 | |
---|
644 | <procedure>(bitwise-first-bit-set VALUE) => INTEGER</procedure> |
---|
645 | |
---|
646 | ==== bitwise-bit-set? |
---|
647 | |
---|
648 | <procedure>(bitwise-bit-set? VALUE INDEX) => BOOLEAN</procedure> |
---|
649 | |
---|
650 | ==== bitwise-copy-bit |
---|
651 | |
---|
652 | <procedure>(bitwise-copy-bit TO START BIT) => INTEGER</procedure> |
---|
653 | |
---|
654 | ==== bitwise-bit-field |
---|
655 | |
---|
656 | <procedure>(bitwise-bit-field VALUE START END) => INTEGER</procedure> |
---|
657 | |
---|
658 | ==== bitwise-copy-bit-field |
---|
659 | |
---|
660 | <procedure>(bitwise-copy-bit-field TO START END FROM) => INTEGER</procedure> |
---|
661 | |
---|
662 | ==== bitwise-rotate-bit-field |
---|
663 | |
---|
664 | <procedure>(bitwise-rotate-bit-field VALUE START END COUNT) => INTEGER</procedure> |
---|
665 | |
---|
666 | ==== bitwise-reverse |
---|
667 | |
---|
668 | <procedure>(bitwise-reverse VALUE COUNT) => INTEGER</procedure> |
---|
669 | |
---|
670 | ==== bitwise-reverse-bit-field |
---|
671 | |
---|
672 | <procedure>(bitwise-reverse-bit-field VALUE START END) => INTEGER</procedure> |
---|
673 | |
---|
674 | ==== bitwise-list->integer |
---|
675 | |
---|
676 | <procedure>(bitwise-list->integer LIST) => INTEGER</procedure> |
---|
677 | |
---|
678 | ==== bitwise-integer->list |
---|
679 | |
---|
680 | <procedure>(bitwise-integer->list VALUE [LENGTH]) => LIST</procedure> |
---|
681 | |
---|
682 | ==== bitwise-arithmetic-shift |
---|
683 | |
---|
684 | <procedure>(bitwise-arithmetic-shift VALUE DIRECTIONAL-COUNT) => INTEGER</procedure> |
---|
685 | |
---|
686 | ==== bitwise-arithmetic-shift-left |
---|
687 | |
---|
688 | <procedure>(bitwise-arithmetic-shift-left VALUE COUNT) => INTEGER</procedure> |
---|
689 | |
---|
690 | ==== bitwise-arithmetic-shift-right |
---|
691 | |
---|
692 | <procedure>(bitwise-arithmetic-shift-right VALUE COUNT) => INTEGER</procedure> |
---|
693 | |
---|
694 | ==== Extras |
---|
695 | |
---|
696 | ===== pow2log2 |
---|
697 | |
---|
698 | <procedure>(pow2log2 VALUE) => INTEGER</procedure> |
---|
699 | |
---|
700 | Returns {{(* 2 (log2 VALUE))}}, but more efficient. |
---|
701 | |
---|
702 | ==== bitwise-last-bit-set |
---|
703 | |
---|
704 | <procedure>(bitwise-last-bit-set VALUE) => INTEGER</procedure> |
---|
705 | |
---|
706 | ===== bitwise-if-not |
---|
707 | |
---|
708 | <procedure>(bitwise-if-not MASK TRUE FALSE) => INTEGER</procedure> |
---|
709 | |
---|
710 | Merge under not mask. |
---|
711 | |
---|
712 | ===== boolean->bit |
---|
713 | |
---|
714 | <procedure>(boolean->bit OBJECT) => INTEGER</procedure> |
---|
715 | |
---|
716 | Returns {{0}} for {{#f}} or {{0}} and {{1}} otherwise. |
---|
717 | |
---|
718 | ===== Unchecked variants |
---|
719 | |
---|
720 | These procedures have the same signature as the similarly named ones but |
---|
721 | perform no argument checking. |
---|
722 | |
---|
723 | ====== *bitwise-if |
---|
724 | ====== *bitwise-if-not |
---|
725 | ====== *bitwise-test? |
---|
726 | ====== *bitwise-bit-count |
---|
727 | ====== *bitwise-length |
---|
728 | ====== *bitwise-first-bit-set |
---|
729 | ====== *bitwise-last-bit-set |
---|
730 | ====== *bitwise-bit-set? |
---|
731 | ====== *bitwise-copy-bit |
---|
732 | ====== *bitwise-bit-field |
---|
733 | ====== *bitwise-copy-bit-field |
---|
734 | ====== *bitwise-rotate-bit-field |
---|
735 | ====== *bitwise-reverse |
---|
736 | ====== *bitwise-reverse-bit-field |
---|
737 | ====== *bitwise-reverse-bit-field |
---|
738 | ====== *bitwise-list->integer |
---|
739 | ====== *bitwise-integer->list |
---|
740 | ====== *bitwise-arithmetic-shift |
---|
741 | ====== *bitwise-arithmetic-shift-left |
---|
742 | ====== *bitwise-arithmetic-shift-right |
---|
743 | ====== *pow2log2 |
---|
744 | |
---|
745 | |
---|
746 | == Usage |
---|
747 | |
---|
748 | |
---|
749 | === Fixnum Arithmetic |
---|
750 | |
---|
751 | <enscript language=scheme> |
---|
752 | (require-library err5rs-arithmetic-fixnums) |
---|
753 | ... |
---|
754 | (import err5rs-arithmetic) |
---|
755 | </enscript> |
---|
756 | |
---|
757 | or |
---|
758 | |
---|
759 | <enscript language=scheme> |
---|
760 | (require-extension err5rs-arithmetic-fixnums) |
---|
761 | </enscript> |
---|
762 | |
---|
763 | |
---|
764 | === Flonum Arithmetic |
---|
765 | |
---|
766 | <enscript language=scheme> |
---|
767 | (require-library err5rs-arithmetic-flonums) |
---|
768 | ... |
---|
769 | (import err5rs-arithmetic) |
---|
770 | </enscript> |
---|
771 | |
---|
772 | or |
---|
773 | |
---|
774 | <enscript language=scheme> |
---|
775 | (require-extension err5rs-arithmetic-flonums) |
---|
776 | </enscript> |
---|
777 | |
---|
778 | |
---|
779 | === Bitwise Arithmetic |
---|
780 | |
---|
781 | <enscript language=scheme> |
---|
782 | (require-library err5rs-arithmetic-bitwise) |
---|
783 | ... |
---|
784 | (import err5rs-arithmetic) |
---|
785 | </enscript> |
---|
786 | |
---|
787 | or |
---|
788 | |
---|
789 | <enscript language=scheme> |
---|
790 | (require-extension err5rs-arithmetic-bitwise) |
---|
791 | </enscript> |
---|
792 | |
---|
793 | |
---|
794 | == Examples |
---|
795 | |
---|
796 | |
---|
797 | == Notes |
---|
798 | |
---|
799 | |
---|
800 | == Requirements |
---|
801 | |
---|
802 | |
---|
803 | == Bugs and Limitations |
---|
804 | |
---|
805 | * No full-numeric-tower arithmetic routines. |
---|
806 | |
---|
807 | * No full-numeric-tower suuport. |
---|
808 | |
---|
809 | |
---|
810 | == Author |
---|
811 | |
---|
812 | [[/users/kon lovett|kon lovett]] |
---|
813 | |
---|
814 | |
---|
815 | == Version history |
---|
816 | |
---|
817 | ; 1.0.0 : Chicken 4 release. |
---|
818 | |
---|
819 | |
---|
820 | == License |
---|
821 | |
---|
822 | Copyright (C) 2009 Kon Lovett. All rights reserved. |
---|
823 | |
---|
824 | Permission is hereby granted, free of charge, to any person obtaining a |
---|
825 | copy of this software and associated documentation files (the Software), |
---|
826 | to deal in the Software without restriction, including without limitation |
---|
827 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
---|
828 | and/or sell copies of the Software, and to permit persons to whom the |
---|
829 | Software is furnished to do so, subject to the following conditions: |
---|
830 | |
---|
831 | The above copyright notice and this permission notice shall be included |
---|
832 | in all copies or substantial portions of the Software. |
---|
833 | |
---|
834 | THE SOFTWARE IS PROVIDED ASIS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
---|
835 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
---|
836 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
---|
837 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
---|
838 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
---|
839 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
---|
840 | OTHER DEALINGS IN THE SOFTWARE. |
---|