flonum-arith.scm 860 B

1234567891011121314151617181920212223242526272829
  1. (define (binary-flonum-op proc)
  2. (lambda (x y)
  3. (save-temp0! x)
  4. (save-temp1! y)
  5. (let ((key (ensure-space double-size)))
  6. (enter-double (proc (extract-double (recover-temp0!))
  7. (extract-double (recover-temp1!)))
  8. key))))
  9. (define flonum-add (binary-flonum-op fl+))
  10. (define flonum-subtract (binary-flonum-op fl-))
  11. (define flonum-multiply (binary-flonum-op fl*))
  12. (define flonum-divide (binary-flonum-op fl/))
  13. (define (flonum-comparison proc)
  14. (lambda (x y)
  15. (proc (extract-double x)
  16. (extract-double y))))
  17. (define flonum= (flonum-comparison fl=))
  18. (define flonum< (flonum-comparison fl<))
  19. (define flonum> (flonum-comparison (lambda (x y)
  20. (fl< y x))))
  21. (define flonum<= (flonum-comparison (lambda (x y)
  22. (not (fl< y x)))))
  23. (define flonum>= (flonum-comparison (lambda (x y)
  24. (not (fl< x y)))))