1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// numera::number::integer::fns
//
//! Integer related standalone functions.
//
use ;
/// Returns the minimum binary bits necessary to represent the given `integer`
/// in the given `base`.
///
/// This is known as the bit length function ([m][0m]).
///
/// [0m]: https://mathworld.wolfram.com/BitLength.html
///
///
/// The `base` must be between 2 and 36, inclusive.
/// Digits 10-35 are represented by a-z or A-Z
///
/// # Examples
/// ```
/// use numera::all::bit_len;
///
/// assert_eq![bit_len(10, "255"), Some(8)];
/// assert_eq![bit_len(16, "FFFFFFFFFFFF"), Some(48)];
/// ```
/// Returns the result of the [`bit_len`] function and the next power of 2.
///
/// From the given `integer` in the given `base`, returns a tuple with the
/// minimum bit-size and the minimum power of two bit-size needed to represent
/// that number.
///
/// The `base` must be between 2 and 36, inclusive.
/// Digits 10-35 are represented by a-z or A-Z
///
/// Returns `None` if the string is not a valid number for the base, which must be
///
/// # Examples
/// ```
/// use numera::all::bit_len_next_power;
///
/// assert_eq![bit_len_next_power(10, "255"), Some((8, 8))];
/// assert_eq![bit_len_next_power(16, "FFFFFFFFFFFF"), Some((48, 64))];
/// ```