MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _sub

Method _sub

tools/python-3.11.9-amd64/Lib/fractions.py:468–480  ·  view source on GitHub ↗

a - b

(a, b)

Source from the content-addressed store, hash-verified

466 __add__, __radd__ = _operator_fallbacks(_add, operator.add)
467
468 def _sub(a, b):
469 """a - b"""
470 na, da = a.numerator, a.denominator
471 nb, db = b.numerator, b.denominator
472 g = math.gcd(da, db)
473 if g == 1:
474 return Fraction(na * db - da * nb, da * db, _normalize=False)
475 s = da // g
476 t = na * (db // g) - nb * s
477 g2 = math.gcd(t, g)
478 if g2 == 1:
479 return Fraction(t, s * db, _normalize=False)
480 return Fraction(t // g2, s * (db // g2), _normalize=False)
481
482 __sub__, __rsub__ = _operator_fallbacks(_sub, operator.sub)
483

Callers

nothing calls this directly

Calls 1

FractionClass · 0.85

Tested by

no test coverage detected