justbases._division module

Long division in any bases.

class justbases._division.NatDivision

Bases: object

Methods for division in arbitrary bases.

classmethod division(divisor, dividend, base, precision=None, method=_RoundingMethod(Round down.))

Division of natural numbers.

Parameters:
  • divisor (list of int) – the divisor
  • dividend (list of int) – the dividend
  • precision (int or NoneType) – maximum number of fractional digits
  • method (element of RoundignMethods.METHODS) – rounding method
Returns:

the result

Return type:

tuple of list of int * list of int * list of int * int

Raises ConvertError:
 

on invalid values

The last value in the result indicates the relationship of the result to the actual value. If 0, it is the same, if 1, greater, if -1, less.

Complexity: Uncalculated

classmethod undivision(integer_part, non_repeating_part, repeating_part, base)

Find divisor and dividend that yield component parts.

Parameters:
  • integer_part (list of int) – the integer part
  • non_repeating_part (list of int) – the non_repeating_part
  • repeating_part (list of int) – the repeating part
  • base (int) – the base
Returns:

divisor and dividend in lowest terms

Return type:

tuple of list of int * list of int

Complexity: O(len(non_repeating_part + repeating_part + integer_part))

Previous topic

justbases._constants module

Next topic

justbases._errors module

This Page