#| -*-Scheme-*-
-$Id: fixart.scm,v 1.13 2003/03/03 12:42:13 cph Exp $
+$Id: fixart.scm,v 1.14 2005/06/30 17:38:33 cph Exp $
Copyright 1994,1996,1999,2000,2001,2003 Massachusetts Institute of Technology
+Copyright 2005 Massachusetts Institute of Technology
This file is part of MIT/GNU Scheme.
(if (not (fix:< object limit))
(error:bad-range-argument object caller)))
-(define-integrable (fix:<= x y)
- (not (fix:> x y)))
+(define-integrable (fix:<= x y) (not (fix:> x y)))
+(define-integrable (fix:>= x y) (not (fix:< x y)))
+(define-integrable (int:<= x y) (not (int:> x y)))
+(define-integrable (int:>= x y) (not (int:< x y)))
+(define (flo:<= x y) (or (flo:< x y) (flo:= x y)))
+(define (flo:>= x y) (or (flo:> x y) (flo:= x y)))
-(define-integrable (fix:>= x y)
- (not (fix:< x y)))
+(define (fix:min n m) (if (fix:< n m) n m))
+(define (fix:max n m) (if (fix:> n m) n m))
-(define (fix:min n m)
- (if (fix:< n m) n m))
-
-(define (fix:max n m)
- (if (fix:> n m) n m))
-
-(define-integrable (int:<= x y)
- (not (int:> x y)))
+(define (flo:min n m)
+ (cond ((flo:< n m) n)
+ ((flo:<= m n) m)
+ (else (error:bad-range-argument n 'FLO:MIN))))
-(define-integrable (int:>= x y)
- (not (int:< x y)))
+(define (flo:max n m)
+ (cond ((flo:> n m) n)
+ ((flo:>= m n) m)
+ (else (error:bad-range-argument n 'FLO:MAX))))
(define-integrable (int:->flonum n)
((ucode-primitive integer->flonum 2) n #b10))
-(define-integrable (flo:<= x y)
- (not (flo:> x y)))
-
-(define-integrable (flo:>= x y)
- (not (flo:< x y)))
-
-(define (flo:min n m)
- (if (flo:< n m) n m))
-
-(define (flo:max n m)
- (if (flo:> n m) n m))
-
(define (->flonum x)
- (if (not (real? x))
- (error:wrong-type-argument x "real number" '->FLONUM))
+ (guarantee-real x '->FLONUM)
(exact->inexact (real-part x)))
(define (flo:finite? x)
- (not (cond ((flo:> x 0.)
- (and (flo:> x 1.)
- (flo:= x (flo:/ x 2.))))
- ((flo:< x 0.)
- (and (flo:< x -1.)
- (flo:= x (flo:/ x 2.))))
- (else
- (flo:= x 0.)))))
\ No newline at end of file
+ (if (or (flo:> x 1.) (flo:< x -1.))
+ (not (flo:= x (flo:/ x 2.)))
+ (and (flo:<= x 1.) (flo:>= x -1.))))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: usiexp.scm,v 4.45 2005/01/06 18:10:44 cph Exp $
+$Id: usiexp.scm,v 4.46 2005/06/30 17:39:12 cph Exp $
Copyright 1987,1988,1989,1990,1991,1992 Massachusetts Institute of Technology
Copyright 1993,1994,1995,1997,2000,2001 Massachusetts Institute of Technology
(constant/make (and expr (object/scode expr))
(string->symbol (constant/value (car operands)))))
(if-not-expanded)))
-\f
+
(define (intern-expansion expr operands if-expanded if-not-expanded block)
block
(if (and (pair? operands)
(ucode-primitive integer->flonum 2)
(list (car operands) (constant/make #f #b10))))
(if-not-expanded)))
-
-(define (flo:<=-expansion expr operands if-expanded if-not-expanded block)
- (if (and (pair? operands)
- (pair? (cdr operands))
- (null? (cddr operands)))
- (if-expanded
- (make-combination
- expr
- block
- (ucode-primitive not)
- (list (make-combination #f
- block
- (ucode-primitive flonum-greater?)
- operands))))
- (if-not-expanded)))
-
-(define (flo:>=-expansion expr operands if-expanded if-not-expanded block)
- (if (and (pair? operands)
- (pair? (cdr operands))
- (null? (cddr operands)))
- (if-expanded
- (make-combination
- expr
- block
- (ucode-primitive not)
- (list (make-combination #f
- block
- (ucode-primitive flonum-less?)
- operands))))
- (if-not-expanded)))
\f
;;;; Tables
fix:<=
fix:=
fix:>=
- flo:<=
- flo:>=
fourth
int:->flonum
int:integer?
fix:<=-expansion
fix:=-expansion
fix:>=-expansion
- flo:<=-expansion
- flo:>=-expansion
fourth-expansion
int:->flonum-expansion
exact-integer?-expansion