diff --git a/src/bigint.rs b/src/bigint.rs index 8472bb3..9145e2e 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -128,7 +128,28 @@ impl BigInt { /// Convert a `&str` or a `String` representing a number in the specified radix to a Bigint. /// /// For radix 10, use the `from` associated function instead. + /// + /// Radix must be between 1 and 36, inclusive, with radix higher + /// than 11 represented by A-Z + /// + /// Only alphanumeric characters are considered, so exponents and + /// other forms are not parsed pub fn from_str_radix(s: T, radix: usize) -> BigInt { + let input = s.to_string(); + + // Convert each digit to it's decimal representation + let mut raw_digits: Vec = Vec::with_capacity(input.len()); + for maybe_digit in input.chars() { + match maybe_digit.to_digit(radix as u32) { + Some(d) => raw_digits.push(d as usize), + None => continue, + } + } + + // Calculate the decimal value by calculating the value + // of each place value + + // In base 1, number of place values = total value todo!(); }