Godtone (talk | contribs)
My Python 3 code: subtle bug in additive arithmetic
Godtone (talk | contribs)
My Python 3 code: correction to softly allow negatives
Line 623: Line 623:
if n==0:
if n==0:
return (0, 1)
return (0, 1)
return unfact(fact( (n,d),p ),p)
r = unfact(fact( (abs(n),abs(d)),p ),p)
return (sgn(n*d)*r[0], r[1])
def striv(n, d=None): # accepted formats: [(n, d, s)], [(n, d), s], [n, d], [n=h]
def striv(n, d=None): # accepted formats: [(n, d, s)], [(n, d), s], [n, d], [n=h]
if d==None and type(n)==tuple and type(n[0])==int and type(n[1])==int:
if d==None and type(n)==tuple and type(n[0])==int and type(n[1])==int: