polymerist.maths.numbersys.positional

Conversion tools for representing positive integers in fixed and mixed radix positional bases

Classes

PositionalNumberingSystem

For representing positive integers in standard and mixed-radix positional numbering systems

Module Contents

class polymerist.maths.numbersys.positional.PositionalNumberingSystem(radices: Sequence[int])[source]

For representing positive integers in standard and mixed-radix positional numbering systems

property radices: Sequence[int]
bases
property places: Generator[int, None, None]

Generates the values of each position in a general mixed-radix positional notation

int_to_digits_iter(n: int) Generator[int, None, None][source]

Convert a non-negative integer to its digit representation under the specified radices Yields digits in ascending order of significance (i.e. starting from least significant digit)

int_to_digits(n: int, as_str: bool = False) str | list[int][source]

Returns digits of number in descending order of significance (i.e. most significant digit first)

digits_to_int(digits: Sequence[int]) int[source]

Convert a sequence of digits to an integer in the specified numbering system Digits should be passed in descending order (i.e. most-significant digit first)