why the inconsistency?

Michael Hudson mwh at python.net
Thu Sep 25 07:17:11 EDT 2003


Christos "TZOTZIOY" Georgiou <tzot at sil-tec.gr> writes:

> On Wed, 24 Sep 2003 19:26:41 +0300, rumours say that Christos "TZOTZIOY"
> Georgiou <tzot at sil-tec.gr> might have written:
> 
> >If only math.log(2**64)/math.log(10) worked with longs without
> >converting them into floats first... :(
> 
> And after reading the FM, if only
> 
> def count_digits(x):
>     return int(math.log(x, 10))
> 
> worked correctly for *all* large values, like 10**70...

Um, it does :-)

>>> float(40**200)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: long int too large to convert to float
>>> math.log(40**200, 14)
279.56038792470861

(10**70 is well within the range of an IEEE double).

Cheers,
mwh

-- 
  I really hope there's a catastrophic bug insome future e-mail
  program where if you try and send an attachment it cancels your
  ISP account, deletes your harddrive, and pisses in your coffee
                                                         -- Adam Rixey




More information about the Python-list mailing list