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

Method _div

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

a / b

(a, b)

Source from the content-addressed store, hash-verified

498 __mul__, __rmul__ = _operator_fallbacks(_mul, operator.mul)
499
500 def _div(a, b):
501 """a / b"""
502 # Same as _mul(), with inversed b.
503 na, da = a.numerator, a.denominator
504 nb, db = b.numerator, b.denominator
505 g1 = math.gcd(na, nb)
506 if g1 > 1:
507 na //= g1
508 nb //= g1
509 g2 = math.gcd(db, da)
510 if g2 > 1:
511 da //= g2
512 db //= g2
513 n, d = na * db, nb * da
514 if d < 0:
515 n, d = -n, -d
516 return Fraction(n, d, _normalize=False)
517
518 __truediv__, __rtruediv__ = _operator_fallbacks(_div, operator.truediv)
519

Callers

nothing calls this directly

Calls 1

FractionClass · 0.85

Tested by

no test coverage detected