Change `/' operation to return an exact integer result when the
authorChris Hanson <org/chris-hanson/cph>
Fri, 2 Sep 1988 04:13:50 +0000 (04:13 +0000)
committerChris Hanson <org/chris-hanson/cph>
Fri, 2 Sep 1988 04:13:50 +0000 (04:13 +0000)
arguments are both exact integers, and the second argument divides the
first.  Otherwise a flonum is returned.

v7/src/microcode/generic.c
v7/src/microcode/version.h
v8/src/microcode/version.h

index 5240b122fd765cb2ea676e5f9498220239db3f63..d747f5a16e3e8996479b2bd3692adbd46fe119cc 100644 (file)
@@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising,
 promotional, or sales literature without prior written consent from
 MIT in each case. */
 
-/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/generic.c,v 9.28 1988/08/16 17:49:29 markf Exp $ */
+/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/generic.c,v 9.29 1988/09/02 04:13:14 cph Rel $ */
 
 #include "scheme.h"
 #include "prims.h"
@@ -746,8 +746,9 @@ DEFINE_PRIMITIVE ("&*", Prim_multiply, 2, 2, 0)
      : (basic_multiply (Arg1, Arg2)));
 }
 \f
-static Pointer basic_divide(Arg1, Arg2)
-fast Pointer Arg1, Arg2;
+static Pointer
+basic_divide(Arg1, Arg2)
+     fast Pointer Arg1, Arg2;
 {
   switch (Type_Code(Arg1))
   { case TC_FIXNUM:
@@ -758,8 +759,10 @@ fast Pointer Arg1, Arg2;
            Sign_Extend(Arg1, A);
            Sign_Extend(Arg2, B);
            if (B==0) Primitive_Error(ERR_ARG_2_BAD_RANGE);
+           if ((A % B) == 0)
+             return (C_Integer_To_Scheme_Integer ((long) (A / B)));
             Result = (double) A / (double) B;
-           Reduced_Flonum_Result(Result);
+           Flonum_Result (Result);
           }
         case TC_BIG_FLONUM:
          { fast long A;
@@ -768,11 +771,6 @@ fast Pointer Arg1, Arg2;
            Primitive_Error(ERR_ARG_2_BAD_RANGE);
            Reduced_Flonum_Result(((double) A) / Get_Float(Arg2));
           }
-
-/* Prim_Divide continues on the next page */
-\f
-/* Prim_Divide, continued */
-
         case TC_BIG_FIXNUM:
          { Pointer Big_Arg1, Result, B;
            long A;
@@ -787,7 +785,7 @@ fast Pointer Arg1, Arg2;
            Sign_Extend(Arg1, A);
            { B = Big_To_Float(Arg2);
              if (Type_Code(B) == TC_BIG_FLONUM)
-             { Reduced_Flonum_Result(A / Get_Float(B));
+             { Flonum_Result(A / Get_Float(B));
              }
              Primitive_Error(ERR_ARG_2_FAILED_COERCION);
            }
@@ -832,11 +830,6 @@ fast Pointer Arg1, Arg2;
        }
        /*NOTREACHED*/
      }
-
-/* Prim_Divide continues on the next page */
-\f
-/* Prim_Divide, continued */
-
     case TC_BIG_FIXNUM:
      { switch (Type_Code(Arg2))
        { case TC_FIXNUM:
@@ -853,7 +846,7 @@ fast Pointer Arg1, Arg2;
            if (Type_Code(A) == TC_BIG_FLONUM)
            { long B;
              Sign_Extend(Arg2, B);
-             Reduced_Flonum_Result(Get_Float(A) / ((double) B));
+             Flonum_Result(Get_Float(A) / ((double) B));
            }
            Primitive_Error(ERR_ARG_1_FAILED_COERCION);
          }
@@ -889,7 +882,7 @@ fast Pointer Arg1, Arg2;
              if (Type_Code(B) == TC_BIG_FLONUM)
              { if (Get_Float(B) == 0)
                  Primitive_Error(ERR_ARG_2_BAD_RANGE);
-               { Reduced_Flonum_Result(Get_Float(A) / Get_Float(B));
+               { Flonum_Result(Get_Float(A) / Get_Float(B));
                }
              }
              Primitive_Error(ERR_ARG_2_FAILED_COERCION);
index 1735f12a68afcd6aa198a033022e001a3d167384..61801f23a23a07be48422ec31c4350952cf50f65 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.50 1988/08/16 18:10:16 markf Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 10.51 1988/09/02 04:13:50 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     50
+#define SUBVERSION     51
 #endif
 
 #ifndef UCODE_TABLES_FILENAME
index 6b64c8f29f2229165310adaa5e1c6733d365dc3e..fe3876912d94a8d12f6e332de85b0d63a676aa3f 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.50 1988/08/16 18:10:16 markf Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 10.51 1988/09/02 04:13:50 cph Exp $
 
 Copyright (c) 1988 Massachusetts Institute of Technology
 
@@ -46,7 +46,7 @@ MIT in each case. */
 #define VERSION                10
 #endif
 #ifndef SUBVERSION
-#define SUBVERSION     50
+#define SUBVERSION     51
 #endif
 
 #ifndef UCODE_TABLES_FILENAME