;; ;; This is the CMLIB version of I1MACH, the integer machine ;; constants subroutine originally developed for the PORT library. ;; ;; I1MACH can be used to obtain machine-dependent parameters ;; for the local machine environment. It is a function ;; subroutine with one (input) argument, and can be called ;; as follows, for example ;; ;; K = I1MACH(I) ;; ;; where I=1,...,16. The (output) value of K above is ;; determined by the (input) value of I. The results for ;; various values of I are discussed below. ;; ;; I/O unit numbers. ;; I1MACH( 1) = the standard input unit. ;; I1MACH( 2) = the standard output unit. ;; I1MACH( 3) = the standard punch unit. ;; I1MACH( 4) = the standard error message unit. ;; ;; Words. ;; I1MACH( 5) = the number of bits per integer storage unit. ;; I1MACH( 6) = the number of characters per integer storage unit. ;; ;; Integers. ;; assume integers are represented in the S-digit, base-A form ;; ;; sign ( X(S-1)*A**(S-1) + ... + X(1)*A + X(0) ) ;; ;; where 0 .LE. X(I) .LT. A for I=0,...,S-1. ;; I1MACH( 7) = A, the base. ;; I1MACH( 8) = S, the number of base-A digits. ;; I1MACH( 9) = A**S - 1, the largest magnitude. ;; ;; Floating-Point Numbers. ;; Assume floating-point numbers are represented in the T-digit, ;; base-B form ;; sign (B**E)*( (X(1)/B) + ... + (X(T)/B**T) ) ;; ;; where 0 .LE. X(I) .LT. B for I=1,...,T, ;; 0 .LT. X(1), and EMIN .LE. E .LE. EMAX. ;; I1MACH(10) = B, the base. ;; ;; Single-Precision ;; I1MACH(11) = T, the number of base-B digits. ;; I1MACH(12) = EMIN, the smallest exponent E. ;; I1MACH(13) = EMAX, the largest exponent E. ;; ;; Double-Precision ;; I1MACH(14) = T, the number of base-B digits. ;; I1MACH(15) = EMIN, the smallest exponent E. ;; I1MACH(16) = EMAX, the largest exponent E. (defun i1mach (i) (ecase i ;; The standard input unit (1 0) ;; The standard output unit (2 1) ;; The standard punch unit (3 3) ;; The standard error message unit (4 2) ;; The number of bits per integer storage unit. What does this ;; mean in Lisp? #+nil (5 (integer-length most-positive-fixnum)) ;; The number of characters per integer storage unit. What does ;; this mean in Lisp? #+nil (6 1) ;; The base of integers. Assume 2's complement (7 2) ;; The number of base-2 digits. Assume fixnum size? (8 (integer-length most-positive-fixnum)) ;; The largest magnitude (9 most-positive-fixnum) ;; Base of floating-poing representation (10 (float-radix 1f0)) ;; Number of digits in representation (11 (float-digits 1f0)) ;; Smallest exponent (12 (multiple-value-bind (frac exp sign) (decode-float least-positive-normalized-single-float) (declare (ignore frac sign)) (+ exp 1))) ;; Largest exponent (13 (multiple-value-bind (frac exp sign) (decode-float most-positive-single-float) (declare (ignore frac sign)) (- exp 1))) ;; Same for double-precision (14 (float-digits 1d0)) (15 (multiple-value-bind (frac exp sign) (decode-float least-positive-normalized-double-float) (declare (ignore frac sign)) (+ exp 1))) (16 (multiple-value-bind (frac exp sign) (decode-float most-positive-double-float) (declare (ignore frac sign)) (- exp 1))) ))