A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-November/040468.html below:

[Python-Dev] Tail recursion

[Python-Dev] Tail recursion [Python-Dev] Tail recursionTim Peters tim.one at comcast.net
Thu Nov 27 12:21:02 EST 2003
[Devin]
> import math
>
> def numdigits(n):
>     assert (n >= 0) and ((n % 1) == 0)
>     if n < 10:
>         return 1
>     return int(math.log10(n)) + 1
>
> (not iterative, but it'll do :)

Nope, integers in Python are unbounded, and this will deliver wrong answers
for "big enough" integers.  Depending on the vagaries of your platform C's
log10 implementation, it may even deliver a wrong answer for small n near an
exact power of 10.


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4