[macruby-changes] [4331] MacRuby/trunk/kernel.c

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 8 14:20:25 PDT 2010


Revision: 4331
          http://trac.macosforge.org/projects/ruby/changeset/4331
Author:   lsansonetti at apple.com
Date:     2010-07-08 14:20:24 -0700 (Thu, 08 Jul 2010)
Log Message:
-----------
fixed bignum promotion when multiplying fixnums

Modified Paths:
--------------
    MacRuby/trunk/kernel.c

Modified: MacRuby/trunk/kernel.c
===================================================================
--- MacRuby/trunk/kernel.c	2010-07-08 03:07:31 UTC (rev 4330)
+++ MacRuby/trunk/kernel.c	2010-07-08 21:20:24 UTC (rev 4331)
@@ -373,8 +373,13 @@
 {
     if (overriden == 0 && NUMERIC_IMM_P(left) && NUMERIC_IMM_P(right)) {
 	if (FIXNUM_P(left) && FIXNUM_P(right)) {
-	    const long res = FIX2LONG(left) * FIX2LONG(right);
-	    if (FIXABLE(res)) {
+	    const long a = FIX2LONG(left);
+	    if (a == 0) {
+		return left;
+	    }
+	    const long b = FIX2LONG(right);
+	    const long res = a * b;
+	    if (FIXABLE(res) && res / a == b) {
 		return LONG2FIX(res);
 	    }
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100708/bf08ec38/attachment.html>


More information about the macruby-changes mailing list