[前][次][番号順一覧][スレッド一覧]

ruby-changes:29008

From: akr <ko1@a...>
Date: Tue, 4 Jun 2013 18:42:37 +0900 (JST)
Subject: [ruby-changes:29008] akr:r41060 (trunk): * bignum.c (bitlength_bdigit): Fix an off-by-one error.

akr	2013-06-04 18:42:25 +0900 (Tue, 04 Jun 2013)

  New Revision: 41060

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41060

  Log:
    * bignum.c (bitlength_bdigit): Fix an off-by-one error.

  Modified files:
    trunk/ChangeLog
    trunk/bignum.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41059)
+++ ChangeLog	(revision 41060)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Jun  4 18:41:47 2013  Tanaka Akira  <akr@f...>
+
+	* bignum.c (bitlength_bdigit): Fix an off-by-one error.
+
 Tue Jun  4 15:30:00 2013  Kenta Murata  <mrkn@c...>
 
 	* ext/bigdecimal/lib/bigdecimal/util.rb (Float#to_d): fix the number
Index: bignum.c
===================================================================
--- bignum.c	(revision 41059)
+++ bignum.c	(revision 41060)
@@ -3193,7 +3193,7 @@ bitlength_bdigit(BDIGIT v) https://github.com/ruby/ruby/blob/trunk/bignum.c#L3193
     v++;
     if (v == 0)
         return SIZEOF_BDIGITS*CHAR_BIT;
-    return ffs(v); /* assumption: sizeof(BDIGIT) <= sizeof(int) */
+    return ffs(v)-1; /* assumption: sizeof(BDIGIT) <= sizeof(int) */
 }
 
 /*

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]