ruby-changes:32831
From: akr <ko1@a...>
Date: Wed, 12 Feb 2014 02:57:02 +0900 (JST)
Subject: [ruby-changes:32831] akr:r44913 (trunk): [DOC]
akr 2014-02-12 01:40:41 +0900 (Wed, 12 Feb 2014) New Revision: 44913 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44913 Log: [DOC] Modified files: trunk/bignum.c trunk/numeric.c Index: numeric.c =================================================================== --- numeric.c (revision 44912) +++ numeric.c (revision 44913) @@ -3538,6 +3538,14 @@ fix_size(VALUE fix) https://github.com/ruby/ruby/blob/trunk/numeric.c#L3538 * (2**12-1).bit_length #=> 12 * (2**12).bit_length #=> 13 * (2**12+1).bit_length #=> 13 + * + * 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 Index: bignum.c =================================================================== --- bignum.c (revision 44912) +++ bignum.c (revision 44913) @@ -6999,6 +6999,13 @@ rb_big_size(VALUE big) https://github.com/ruby/ruby/blob/trunk/bignum.c#L6999 * (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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/