From c97f5f514a63f2b5ed909aec270e89efb0c2703d Mon Sep 17 00:00:00 2001 From: akr Date: Wed, 31 Mar 2010 19:56:04 +0000 Subject: [PATCH] * time.c (rb_big_abs_find_minbit): fix handling the last word. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ test/ruby/test_time.rb | 2 ++ time.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d7231176b9..017dbc1d93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Apr 1 04:55:08 2010 Tanaka Akira + + * time.c (rb_big_abs_find_minbit): fix handling the last word. + Thu Apr 1 04:30:11 2010 Tanaka Akira * time.c (long_mul): overflow condition changed. diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 108fcdbc20..cb17f416ee 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -181,6 +181,8 @@ class TestTime < Test::Unit::TestCase assert_equal(-146138510344, t.year) t = Time.at(-0x5000_0000_0000_0001) assert_equal(-182673138422, t.year) + t = Time.at(-0x6000_0000_0000_0000) + assert_equal(-219207766501, t.year) end def test_at2 diff --git a/time.c b/time.c index a3195e27a2..e36c33bdcb 100644 --- a/time.c +++ b/time.c @@ -343,7 +343,7 @@ rb_big_abs_find_minbit(VALUE big) return Qnil; res = mul(LONG2NUM(i), INT2FIX(SIZEOF_BDIGITS * CHAR_BIT)); d = ds[i]; - res = add(res, LONG2FIX(bdigit_find_maxbit(d))); + res = add(res, LONG2FIX(bdigit_find_maxbit(d & -d))); return res; }