fn bit_length(_: &mut VM, self_val: Value, args: &Args2) -> VMResult {
    args.check_args_num(0)?;
    let bits = if let Some(i) = self_val.as_fixnum() {
        if i >= 0 {
            64 - i.leading_zeros()
        } else {
            64 - i.leading_ones()
        }
    } else if let Some(b) = self_val.as_bignum() {
        let all = ((b.bits() + 63) / 64 * 64) as usize;
        let lead = if !b.is_negative() {
            (0..all).into_iter().find(|x| b.bit((all - *x) as u64))
        } else {
            (0..all).into_iter().find(|x| !b.bit((all - *x) as u64))
        }
        .unwrap_or(all) as u32;
        all as u32 - lead + 1
    } else {
        unreachable!()
    };
    Ok(Value::integer(bits as i64))
}
bit_length -> Integer

https://docs.ruby-lang.org/ja/latest/method/Integer/i/bit_length.html
ruruby/src/builtin/integer.rs