Module base

Module base 

Source
Expand description

Base conversion

Structs§

Base
Represents a mathematical integer base / radix (e.g. 1, 2, 8, 10, 16, 64).
BaseConversionPaddingMode
Zero-padding configuration for delimited base string conversion.
BaseStringFormatSettings
Settings for parsing and formatting delimited strings of numbers across bases.
NumeralSystem
Represents a numeral system defined by a mathematical radix and a digit alphabet.

Enums§

BaseAlphabet
Alphabet used by a numeral system.

Functions§

base_to_base_string
Parse a string containing numbers in base 2 through 64, convert it to the target base, and print it formatted. Will warn for extra characters other than spaces and commas.
casefold_base_chars_in_string
char_from_hex_byte
Convert two hex digits to a single byte -> char (StageL: charFromHexByte). StageL operated on bytes, not Unicode scalar validation beyond 0xFF.
dec_to_hex_single
dec_to_hex_string
Convenience function to convert a delimited string of decimal numbers to hexadecimal using default format settings.
format_base_string
Parse a string containing numbers in base 2 through 64 and print it formatted. Will warn for extra characters other than spaces and commas.
get_digits_needed
hex_to_dec_single
hex_to_dec_string
Convenience function to convert a delimited string of hexadecimal numbers to decimal using default format settings.
int_from_base36_char
Returns an int given the nth digit in base 36 or less (using capitalized digits).
int_from_base_str_big
Returns the integer represented by n in the requested base.
int_from_base_str_big_alphabet
Returns the integer represented by n in the requested base using the given alphabet.
int_from_base_str_u32
Returns the integer represented by n in the requested base.
int_from_base_str_u128
Returns the integer represented by n in the requested base.
int_to_base36_char
Returns the nth digit in base 36 or less (using capitalized digits). The original JS version had a bug where it would accept 36 as a base, when 0 to 35 is expected (36 digits).
int_to_base_str
Returns the integer represented by n in the requested base.
int_to_base_str_big_alphabet
Returns the string representation of an arbitrary-precision integer in the requested base and alphabet.
is_base_digit
Returns true if the single-character string is a valid digit in the standard alphabet for the given base.
is_base_digit_alphabet
Returns true if the character is a valid digit for the given base in the specified alphabet.
is_base_str
Returns true if all characters in the string are valid digits in the standard alphabet for the given base.
is_base_str_alphabet
Returns true if all characters in the string are valid digits for the given base in the specified alphabet.
is_supported_base
Returns true if the base is supported by the standard alphanumeric alphabet (1..=36).