Miscellaneous utilities.
Convert magnitude to a decimal string.
Parameters: |
|
---|---|
Returns: | a string representation of value |
Return type: | str |
Since a rational number may be a non-terminating decimal quantity, this representation is not guaranteed to be exact, regardless of the value of places.
Even in the case of a terminating decimal representation, the representation may be inexact if the number of significant digits is too large for the precision of the Decimal operations as specified by the context.
Get value as a possibly repeating decimal.
Parameters: | value (any precise numerical quantity) – the value |
---|---|
Returns: | a precise decimal representation of the number |
Return type: | tuple of int * list of int * int |
The parts represent the non-fractional part, the fractional part including the first repeating part, the length of the repeating part.
Get the repeating decimal number corresponding to the ratio of numerator and denominator.
Parameters: | |
---|---|
Returns: | a list of decimal digits and a number indicating length of repeat |
Return type: | tuple of (list of int) * int |
Prereq: numerator < denominator, denominator > 0, numerator >= 0
Get information about the string that represents this magnitude.
Parameters: |
|
---|---|
Returns: | a pair, indicating whether the value is exact and the value |
Rtypes: | tuple of bool * str |
Precise division of two precise quantities.
Parameters: |
|
---|---|
Returns: | the result of long division |
Return type: | a tuple of int * list * list |
:raises SizeValueError: on bad input
The result is the number to the left of the decimal point, a list of the non-repeating digits to the right of the decimal point, and a list of the repeating digits.
Round a fraction to an integer according to rounding method.
Parameters: |
|
---|---|
Returns: | a rounded integer |
Return type: | int |