Imports name this capability’s declared dependencies, which fune builds next to it in your project; each one links to its page.
from .math_rational_rational import rational_from_wide, rational_parts ← rational, another function of this group · built into the same file, even by a slim install
from .math_rational_types import Rational
def divide_rational(a: Rational, b: Rational) -> Rational:
"""a ÷ b, reduced. Dividing by zero is an error, never an infinity."""
an, ad = rational_parts(a)
bn, bd = rational_parts(b)
if bn == 0:
raise ValueError("division by zero")
return rational_from_wide(an * bd, ad * bn)