From ca7c9ff157d4aeab05e3ccf32388136553dc2fed Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 29 Jan 2004 13:55:42 +0000 Subject: [PATCH] * src/math.c: + If one of the factors is the exact zero, the result yields exact zero. git-svn-id: svn://svn.zoy.org/elk/trunk@249 55e467fa-43c5-0310-a8a2-de718669efc6 --- src/math.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/math.c b/src/math.c index 13d799a..190b916 100644 --- a/src/math.c +++ b/src/math.c @@ -746,6 +746,8 @@ Object Generic_Multiply (Object x, Object y) { switch (TYPE(x)) { case T_Fixnum: + if(FIXNUM(x) == 0) + return Zero; switch (TYPE(y)) { case T_Fixnum: ret = Fixnum_Multiply (FIXNUM(x), FIXNUM(y)); @@ -764,6 +766,8 @@ Object Generic_Multiply (Object x, Object y) { case T_Flonum: switch (TYPE(y)) { case T_Fixnum: + if(FIXNUM(y) == 0) + return Zero; return Make_Flonum (FLONUM(x)->val * FIXNUM(y)); case T_Flonum: return Make_Flonum (FLONUM(x)->val * FLONUM(y)->val); @@ -775,6 +779,8 @@ Object Generic_Multiply (Object x, Object y) { case T_Bignum: switch (TYPE(y)) { case T_Fixnum: + if(FIXNUM(y) == 0) + return Zero; return Bignum_Fixnum_Multiply (x, y); case T_Flonum: return Make_Flonum (Bignum_To_Double (x) * FLONUM(y)->val);