[MacRuby/MacRuby] 9130bd: fix an overflow by multiplying
Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: 9130bd366d5dd62aa847a8cef8a02c1c3f82f4d2 https://github.com/MacRuby/MacRuby/commit/9130bd366d5dd62aa847a8cef8a02c1c3f... Author: Watson <watson1978@gmail.com> Date: 2012-05-15 (Tue, 15 May 2012) Changed paths: M kernel.c Log Message: ----------- fix an overflow by multiplying if multiply Fixnum value between about half of max of long type (32bit), calculated value is broken. Test Script ---- require 'test/unit/assertions.rb' include Test::Unit::Assertions a = 2147483648 b = 2147483647 assert_equal(4611686016279904256, a * b) assert_equal(-4611686016279904256, (-a) * b) assert_equal(-4611686016279904256, a * (-b)) assert_equal(4611686016279904256, (-a) * (-b))
participants (1)
-
GitHub