Skip to main content

digit_from_display_byte_large

Function digit_from_display_byte_large 

Source
pub const fn digit_from_display_byte_large(b: u8) -> Option<u8>
Expand description

Converts a byte corresponding to a numeric or alphabetic char to a digit in the large-base alphabet used for bases from 37 through 62, in which the uppercase and lowercase letters are distinct digits: b'0' through b'9' represent 0 through 9, b'A' through b'Z' represent 10 through 35, and b'a' through b'z' represent 36 through 61, as in GMP.

Bytes that don’t correspond to any digit are converted to None.

§Worst-case complexity

Constant time and additional memory.

§Examples

use malachite_base::num::conversion::string::from_string::digit_from_display_byte_large;

assert_eq!(digit_from_display_byte_large(b'0'), Some(0));
assert_eq!(digit_from_display_byte_large(b'A'), Some(10));
assert_eq!(digit_from_display_byte_large(b'Z'), Some(35));
assert_eq!(digit_from_display_byte_large(b'a'), Some(36));
assert_eq!(digit_from_display_byte_large(b'z'), Some(61));
assert_eq!(digit_from_display_byte_large(b'!'), None);