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

Method _add

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

a + b

(a, b)

Source from the content-addressed store, hash-verified

450 # rationals, obtained from floats.
451
452 def _add(a, b):
453 """a + b"""
454 na, da = a.numerator, a.denominator
455 nb, db = b.numerator, b.denominator
456 g = math.gcd(da, db)
457 if g == 1:
458 return Fraction(na * db + da * nb, da * db, _normalize=False)
459 s = da // g
460 t = na * (db // g) + nb * s
461 g2 = math.gcd(t, g)
462 if g2 == 1:
463 return Fraction(t, s * db, _normalize=False)
464 return Fraction(t // g2, s * (db // g2), _normalize=False)
465
466 __add__, __radd__ = _operator_fallbacks(_add, operator.add)
467

Callers

nothing calls this directly

Calls 1

FractionClass · 0.85

Tested by

no test coverage detected