home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mitsch75.zip / scheme-7_5_17-src.zip / scheme-7.5.17 / src / runtime / fixart.scm < prev    next >
Text File  |  2001-02-10  |  4KB  |  143 lines

  1. #| -*-Scheme-*-
  2.  
  3. $Id: fixart.scm,v 1.6 2001/02/11 00:08:16 cph Exp $
  4.  
  5. Copyright (c) 1988-2001 Massachusetts Institute of Technology
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful, but
  13. WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. |#
  21.  
  22. ;;;; Fixnum Arithmetic
  23. ;;; package: ()
  24.  
  25. (declare (usual-integrations))
  26.  
  27. (define-primitives
  28.   (fix:fixnum? fixnum? 1)
  29.   (fixnum? fixnum? 1)
  30.   (index-fixnum? index-fixnum? 1)
  31.   (fix:zero? zero-fixnum? 1)
  32.   (fix:negative? negative-fixnum? 1)
  33.   (fix:positive? positive-fixnum? 1)
  34.   (fix:= equal-fixnum? 2)
  35.   (fix:< less-than-fixnum? 2)
  36.   (fix:> greater-than-fixnum? 2)
  37.   (fix:1+ one-plus-fixnum 1)
  38.   (fix:-1+ minus-one-plus-fixnum 1)
  39.   (fix:+ plus-fixnum 2)
  40.   (fix:- minus-fixnum 2)
  41.   (fix:* multiply-fixnum 2)
  42.   (fix:divide divide-fixnum 2)
  43.   (fix:quotient fixnum-quotient 2)
  44.   (fix:remainder fixnum-remainder 2)
  45.   (fix:gcd gcd-fixnum 2)
  46.   (fix:andc fixnum-andc 2)
  47.   (fix:and fixnum-and 2)
  48.   (fix:or fixnum-or 2)
  49.   (fix:xor fixnum-xor 2)
  50.   (fix:not fixnum-not 1)
  51.   (fix:lsh fixnum-lsh 2)
  52.  
  53.   (int:integer? integer? 1)
  54.   (int:zero? integer-zero? 1)
  55.   (int:positive? integer-positive? 1)
  56.   (int:negative? integer-negative? 1)
  57.   (int:= integer-equal? 2)
  58.   (int:< integer-less? 2)
  59.   (int:> integer-greater? 2)
  60.   (int:negate integer-negate 1)
  61.   (int:1+ integer-add-1 1)
  62.   (int:-1+ integer-subtract-1 1)
  63.   (int:+ integer-add 2)
  64.   (int:- integer-subtract 2)
  65.   (int:* integer-multiply 2)
  66.   (int:divide integer-divide 2)
  67.   (int:quotient integer-quotient 2)
  68.   (int:remainder integer-remainder 2)
  69.  
  70.   (flo:flonum? flonum? 1)
  71.   (flo:zero? flonum-zero? 1)
  72.   (flo:positive? flonum-positive? 1)
  73.   (flo:negative? flonum-negative? 1)
  74.   (flo:= flonum-equal? 2)
  75.   (flo:< flonum-less? 2)
  76.   (flo:> flonum-greater? 2)
  77.   (flo:+ flonum-add 2)
  78.   (flo:- flonum-subtract 2)
  79.   (flo:* flonum-multiply 2)
  80.   (flo:/ flonum-divide 2)
  81.   (flo:negate flonum-negate 1)
  82.   (flo:abs flonum-abs 1)
  83.   (flo:exp flonum-exp 1)
  84.   (flo:log flonum-log 1)
  85.   (flo:sin flonum-sin 1)
  86.   (flo:cos flonum-cos 1)
  87.   (flo:tan flonum-tan 1)
  88.   (flo:asin flonum-asin 1)
  89.   (flo:acos flonum-acos 1)
  90.   (flo:atan flonum-atan 1)
  91.   (flo:atan2 flonum-atan2 2)
  92.   (flo:sqrt flonum-sqrt 1)
  93.   (flo:expt flonum-expt 2)
  94.   (flo:floor flonum-floor 1)
  95.   (flo:ceiling flonum-ceiling 1)
  96.   (flo:truncate flonum-truncate 1)
  97.   (flo:round flonum-round 1)
  98.   (flo:floor->exact flonum-floor->exact 1)
  99.   (flo:ceiling->exact flonum-ceiling->exact 1)
  100.   (flo:truncate->exact flonum-truncate->exact 1)
  101.   (flo:round->exact flonum-round->exact 1)
  102.   (flo:vector-cons floating-vector-cons 1)
  103.   (flo:vector-length floating-vector-length 1)
  104.   (flo:vector-ref floating-vector-ref 2)
  105.   (flo:vector-set! floating-vector-set! 3))
  106.  
  107. (define-integrable (fix:<= x y)
  108.   (not (fix:> x y)))
  109.  
  110. (define-integrable (fix:>= x y)
  111.   (not (fix:< x y)))
  112.  
  113. (define (fix:min n m)
  114.   (if (fix:< n m) n m))
  115.  
  116. (define (fix:max n m)
  117.   (if (fix:> n m) n m))
  118.  
  119. (define-integrable (int:<= x y)
  120.   (not (int:> x y)))
  121.  
  122. (define-integrable (int:>= x y)
  123.   (not (int:< x y)))
  124.  
  125. (define-integrable (int:->flonum n)
  126.   ((ucode-primitive integer->flonum 2) n #b10))
  127.  
  128. (define-integrable (flo:<= x y)
  129.   (not (flo:> x y)))
  130.  
  131. (define-integrable (flo:>= x y)
  132.   (not (flo:< x y)))
  133.  
  134. (define (flo:min n m)
  135.   (if (flo:< n m) n m))
  136.  
  137. (define (flo:max n m)
  138.   (if (flo:> n m) n m))
  139.  
  140. (define (->flonum x)
  141.   (if (not (real? x))
  142.       (error:wrong-type-argument x "real number" '->FLONUM))
  143.   (exact->inexact (real-part x)))