Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

Internally, the math.log10() function only works on floats.  By way of the 
__float__() method, the input to the the math.log10() function is asked to 
convert itself to a float.  Fractions implement __float__() by just dividing 
the numerator and denominator.  In your example, the result is smaller than the 
smallest representable positive float (2**-1074), so the result gets rounded 
down to 0.0.  The log10() function isn't defined for zero:

    >>> f = Fraction(factorial(10000), factorial(20000)+1)
    >>> float(f)
    0.0
    >>> log10(f)
    Traceback (most recent call last):
      ...
    ValueError: math domain error

Short of adding a log10() method to the Fraction class, there isn't a straight 
forward way to accommodate getting this to work.

----------
nosy: +rhettinger

_______________________________________
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