Fractions#
Module introducing all the functions used to handle fractions.
- frac(*arg: Numeric) Numeric [source]#
Returns a fraction instantiated from the module defined by the FRACTION constant. If more than two numbers are provided, an error is raised.
- Parameters:
Numeric – One or two numbers.
- Returns:
The fraction.
- Return type:
Numeric
- str_as_frac(s: str) Numeric [source]#
Converts a string to a fraction instantiated from the module defined by the FRACTION constant.
- Parameters:
s (str) – A string representing a number.
- Returns:
The fraction.
- Return type:
Numeric
- FLOAT_FRAC = 'float'#
Value of the FRACTION constant when float fractions are to be used.
- FRACTION = 'gmpy2'#
Constant describing which module to use for computing fractions. It can either be “gmpy2” or “float”. The default is “gmpy2”.
- GMPY_FRAC = 'gmpy2'#
Value of the FRACTION constant when gumpy2 fractions are to be used.