From 2fee22f30dae1d2998f293d0b0ec2b368ceb34d6 Mon Sep 17 00:00:00 2001 From: akr Date: Tue, 11 Feb 2014 16:40:41 +0000 Subject: [DOC] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- numeric.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'numeric.c') diff --git a/numeric.c b/numeric.c index cc9c63e3d1..4bb2c3a534 100644 --- a/numeric.c +++ b/numeric.c @@ -3538,6 +3538,14 @@ fix_size(VALUE fix) * (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 -- cgit v1.2.1