New submission from Camion <camion_spam-pyb...@yahoo.com>:

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

----------
components: Library (Lib)
messages: 384783
nosy: Camion
priority: normal
severity: normal
status: open
title: math.log and math.log10 domain error on very large Fractions
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42886>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to