Message384783
Python is able to computer the logarithms of very large integers and fractions (by using log(num)-log(denom)), However the fractions.Fraction class fails to do it and raises a math domain error exception.
>>> import math, fractions
>>> f=fractions.Fraction(math.factorial(10000), math.factorial(20000)+1)
>>> math.log(f.numerator)-math.log(f.denominator)
-95966.69390038431
>>> math.log(f)
Traceback (most recent call last):
File "<pyshell#30>", line 1, in <module>
math.log(f)
ValueError: math domain error
>>> math.log10(f.numerator)-math.log10(f.denominator)
-41677.80560743537
>>> math.log10(f)
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
math.log10(f)
ValueError: math domain error |
|
Date |
User |
Action |
Args |
2021-01-10 22:44:43 | Camion | set | recipients:
+ Camion |
2021-01-10 22:44:43 | Camion | set | messageid: <1610318683.55.0.0487505722004.issue42886@roundup.psfhosted.org> |
2021-01-10 22:44:43 | Camion | link | issue42886 messages |
2021-01-10 22:44:43 | Camion | create | |
|