Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Log base 2 of large integers Date: Wed, 13 Aug 2014 17:00:26 +0300 Organization: A noiseless patient Spider Lines: 87 Message-ID: <87a978v69x.fsf@elektro.pacujo.net> References: <53eb6903$0$29982$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="23406"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19i7fBi/4yGFPEfowtM2yqC" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:9/BIxrImcUw44SWo2cCcRJEP5pw= sha1:XpkBX7z/oocKJ8jMaxfenrvWJv8= Xref: csiph.com comp.lang.python:76201 Mok-Kong Shen : >>> I like to compute log base 2 of a fairly large integer n but >>> with math.log(n,2) I got: >>> >>> OverflowError: long int too large to convert to float. >>> math.log(77777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 777777777777777777777777777777777777777777777777777777777777777777777777777= 77777777777777777777777777777777777777777, 2) 18270.24195180111 How big an integer are we talking about? Marko