Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; ';-)': 0.03; '(python': 0.07; 'float': 0.07; 'method.': 0.07; 'skip:2 30': 0.09; 'subject:number': 0.09; 'python': 0.11; 'all?': 0.16; 'argument.': 0.16; 'operation,': 0.16; 'subject:skip:m 10': 0.16; 'supplied': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'stopping': 0.24; 'math': 0.24; 'paul': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'bigger': 0.30; '"",': 0.31; 'writes:': 0.31; 'file': 0.32; 'subject:all': 0.32; '(most': 0.33; "i'd": 0.34; 'problem': 0.35; 'but': 0.35; 'doing': 0.36; 'too': 0.37; 'represent': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'dave': 0.60; 'skip:2 20': 0.60; 'range': 0.61; 'first': 0.61; 'real': 0.63; 'charset:windows-1252': 0.65; 'received:74.208': 0.68; 'bignums': 0.84; 'divide': 0.84; 'received:74.208.4.194': 0.84; 'subject:find': 0.84; 'angel': 0.91 Date: Mon, 13 Apr 2015 00:35:02 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: find all multiplicands and multipliers for a number References: <890bd388-f50a-4dec-9ef5-27715427472a@googlegroups.com> <55288135$0$12997$c3e8da3$5496439d@news.astraweb.com> <87egnrb3il.fsf@jester.gateway.sonic.net> <87619387c0.fsf@elektro.pacujo.net> <90a8e07c-adb3-499f-8971-4ea49f6aea4b@googlegroups.com> <87lhhx7r44.fsf@elektro.pacujo.net> <87zj6czt84.fsf@jester.gateway.sonic.net> <87vbh0zow3.fsf@jester.gateway.sonic.net> In-Reply-To: <87vbh0zow3.fsf@jester.gateway.sonic.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:6uipwmi9vIAvB3BKAcosNFEMEgGw7CBdOjGnvLB+osKrrA/pdV5 UlMZEy+WQQxOli5DrllAhAOis+WDj2lVMsm2xoiLYCZsiNZqNcVfjoxPKKwF2R/3eDpxXgn TCgucUcxLn+wu1JwirHaTG3vBShjfZHye31xGQ/xNALQpdhaC/1O6jEHUF7nFA+KFSC8F1k UCiSoNEYrfMoxIIeawOfQ== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1428899720 news.xs4all.nl 2921 [2001:888:2000:d::a6]:34007 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:88908 On 04/12/2015 11:30 PM, Paul Rubin wrote: > Dave Angel writes: >> If I were trying to get a bound for stopping the divide operation, on >> a value too large to do exact real representation, I'd try doing just >> a few iterations of Newton's method. > > Python ninja trick: math.log works on bignums too large to be > represented as floats ;-) > But doesn't math.pow return a float? Af first crack I figured it was because I had supplied math.e as the first argument. But I have the same problem with (python 3.4) x = 2596148429267413814265248164610047 print( math.pow(2, math.log2(x)) ) 2.596148429267414e+33 Or were you saying bignums bigger than a float can represent at all? Like: >>> x = 2**11111 -1 >>> len(str(x)) 3345 >>> math.log2(x) 11111.0 >>> math.pow(2, math.log2(x)//2) Traceback (most recent call last): File "", line 1, in OverflowError: math range error -- DaveA