Open
Description
Documentation
This suggestion is to clarify the current behavior of the fractions
module.
The current implementation of Fraction
reduces an input numerator and a denominator so that the latter is positive, which is implemented in the following places:
Lines 299 to 303 in d27a53f
This behavior is partially documented in https://docs.python.org/3.14/library/fractions.html:
- numerator
- Numerator of the Fraction in lowest term.
- denominator
- Denominator of the Fraction in lowest term.
- as_integer_ratio()
- Return a tuple of two integers, whose ratio is equal to the original Fraction. The ratio is in lowest terms and has a positive denominator.
It says that a denominator returned by as_integer_ratio
is positive, but doesn't mention to the sign of the denominator
property. I think there should be no problem with making that explicit also in the explanation of denominator
.