From: Chris Hanson Date: Sat, 12 Jun 2004 02:14:56 +0000 (+0000) Subject: Implement SMALLEST-FIXNUM and LARGEST-FIXNUM. X-Git-Tag: 20090517-FFI~1641 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=d7f59d586db3053f770e5cb90b17459e8aadc75f;p=mit-scheme.git Implement SMALLEST-FIXNUM and LARGEST-FIXNUM. --- diff --git a/v7/src/runtime/arith.scm b/v7/src/runtime/arith.scm index 8e122fdbb..fdb0aad09 100644 --- a/v7/src/runtime/arith.scm +++ b/v7/src/runtime/arith.scm @@ -1,10 +1,10 @@ #| -*-Scheme-*- -$Id: arith.scm,v 1.58 2003/04/19 04:23:41 cph Exp $ +$Id: arith.scm,v 1.59 2004/06/12 02:14:41 cph Exp $ Copyright 1989,1990,1991,1992,1993,1994 Massachusetts Institute of Technology Copyright 1995,1996,1997,1999,2001,2002 Massachusetts Institute of Technology -Copyright 2003 Massachusetts Institute of Technology +Copyright 2003,2004 Massachusetts Institute of Technology This file is part of MIT/GNU Scheme. @@ -97,6 +97,8 @@ USA. (define flo:significand-digits-base-2) (define flo:significand-digits-base-10) (define int:flonum-integer-limit) +(define fix:largest-value) +(define fix:smallest-value) (define (initialize-microcode-dependencies!) (let ((p microcode-id/floating-mantissa-bits)) @@ -114,6 +116,12 @@ USA. (set! int:flonum-integer-limit (int:expt 2 p))) unspecific) +(define (largest-fixnum) + fix:largest-value) + +(define (smallest-fixnum) + fix:smallest-value) + (define (initialize-package!) (initialize-microcode-dependencies!) (add-event-receiver! event:after-restore initialize-microcode-dependencies!) @@ -253,6 +261,21 @@ USA. (max/min max complex:max) (max/min min complex:min)) + (let loop ((n 1)) + (if (fix:fixnum? n) + (loop (* n 2)) + (let ((n (- n 1))) + (if (not (fix:fixnum? n)) + (error "Unable to compute largest fixnum:" n)) + (set! fix:largest-value n)))) + (let loop ((n -1)) + (if (fix:fixnum? n) + (loop (* n 2)) + (let ((n (quotient n 2))) + (if (not (fix:fixnum? n)) + (error "Unable to compute smallest fixnum:" n)) + (set! fix:smallest-value n)))) + unspecific) (define (int:max n m) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index 50bd811fe..6fe6c6b27 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: runtime.pkg,v 14.486 2004/06/07 19:47:57 cph Exp $ +$Id: runtime.pkg,v 14.487 2004/06/12 02:14:56 cph Exp $ Copyright 1988,1989,1990,1991,1992,1993 Massachusetts Institute of Technology Copyright 1994,1995,1996,1997,1998,1999 Massachusetts Institute of Technology @@ -2310,6 +2310,7 @@ USA. inexact? integer-divide-quotient integer-divide-remainder + largest-fixnum lcm max min @@ -2318,6 +2319,7 @@ USA. odd? quotient remainder + smallest-fixnum square) (initialization (begin