aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 11:17:37 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-04-26 11:17:37 +0000
commitbcc17969832e8f40200231f1a925c8f2318aa706 (patch)
treee2caeb465d38e523ed8e819c9f2ecf2a5c7528da /bignum.c
parent9368d7515b9886267ebe7602218e4ac2ea494074 (diff)
downloadruby-bcc17969832e8f40200231f1a925c8f2318aa706.tar.gz
{Fixnum,Bignum}#bit_length is unified into Integer.
* numeric.c (rb_int_bit_length): {Fixnum,Bignum}#bit_length is unified into Integer. * bignum.c (rb_big_bit_length): Don't define Bignum#bit_length. * internal.h (rb_big_bit_length): Declared. --This iine, and those below, will be ignored-- M ChangeLog M bignum.c M internal.h M numeric.c git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c40
1 files changed, 1 insertions, 39 deletions
diff --git a/bignum.c b/bignum.c
index 6fcbc74783..c87fdaa0fb 100644
--- a/bignum.c
+++ b/bignum.c
@@ -6920,45 +6920,7 @@ rb_big_size_m(VALUE big)
return SIZET2NUM(rb_big_size(big));
}
-/*
- * call-seq:
- * int.bit_length -> integer
- *
- * Returns the number of bits of the value of <i>int</i>.
- *
- * "the number of bits" means that
- * the bit position of the highest bit which is different to the sign bit.
- * (The bit position of the bit 2**n is n+1.)
- * If there is no such bit (zero or minus one), zero is returned.
- *
- * I.e. This method returns ceil(log2(int < 0 ? -int : int+1)).
- *
- * (-2**10000-1).bit_length #=> 10001
- * (-2**10000).bit_length #=> 10000
- * (-2**10000+1).bit_length #=> 10000
- *
- * (-2**1000-1).bit_length #=> 1001
- * (-2**1000).bit_length #=> 1000
- * (-2**1000+1).bit_length #=> 1000
- *
- * (2**1000-1).bit_length #=> 1000
- * (2**1000).bit_length #=> 1001
- * (2**1000+1).bit_length #=> 1001
- *
- * (2**10000-1).bit_length #=> 10000
- * (2**10000).bit_length #=> 10001
- * (2**10000+1).bit_length #=> 10001
- *
- * This method can be used to detect overflow in Array#pack as follows.
- *
- * if n.bit_length < 32
- * [n].pack("l") # no overflow
- * else
- * raise "overflow"
- * end
- */
-
-static VALUE
+VALUE
rb_big_bit_length(VALUE big)
{
int nlz_bits;