Re: long int computations

2010-05-06 Thread Duncan Booth
Peter Otten <__pete...@web.de> wrote: > Victor Eijkhout wrote: > >> I have two long ints, both too long to convert to float, but their ratio >> is something reasonable. How can I compute that? The obvious "(1.*x)/y" >> does not work. > import fractions x = 12345 * 10**1000 y = 765

Re: long int computations

2010-05-06 Thread Mark Dickinson
On May 3, 9:49 pm, s...@sig.for.address (Victor Eijkhout) wrote: > Jerry Hill wrote: > > >>> from __future__ import division > > >>> long1/long2 > > 0.5 > > Beautiful. Thanks so much guys. And if for some reason you don't want to use the 'from __future__' import, then you can do long1.__truediv__

Re: long int computations

2010-05-06 Thread Paul Rubin
s...@sig.for.address (Victor Eijkhout) writes: > I have two long ints, both too long to convert to float, but their ratio > is something reasonable. How can I compute that? The obvious "(1.*x)/y" > does not work. The math.log function has a special hack for long ints, that might help: Python

Re: long int computations

2010-05-04 Thread Victor Eijkhout
Mensanator wrote: > You could try using the gmpy module. It supports arbitrary precision > floats, so converting long to float is no problem. I fear I may actually have to go symbolic. I'm now having to use the 12th root of 2, and I would like the twelfth power of that to be exactly 2. Victor.

Re: long int computations

2010-05-04 Thread Mensanator
On May 3, 10:17 am, s...@sig.for.address (Victor Eijkhout) wrote: > I have two long ints, both too long to convert to float, but their ratio > is something reasonable. How can I compute that? The obvious "(1.*x)/y" > does not work. You could try using the gmpy module. It supports arbitrary precisi

Re: long int computations

2010-05-03 Thread Victor Eijkhout
Jerry Hill wrote: > >>> from __future__ import division > >>> long1/long2 > 0.5 Beautiful. Thanks so much guys. Victor. -- Victor Eijkhout -- eijkhout at tacc utexas edu -- http://mail.python.org/mailman/listinfo/python-list

Re: long int computations

2010-05-03 Thread Peter Otten
Peter Pearson wrote: > On Mon, 03 May 2010 17:30:03 +0200, Peter Otten <__pete...@web.de> wrote: >> Victor Eijkhout wrote: >> >>> I have two long ints, both too long to convert to float, but their ratio >>> is something reasonable. How can I compute that? The obvious "(1.*x)/y" >>> does not work.

Re: long int computations

2010-05-03 Thread Jussi Piitulainen
Peter Otten writes: > Victor Eijkhout wrote: > > > I have two long ints, both too long to convert to float, but their > > ratio is something reasonable. How can I compute that? The obvious > > "(1.*x)/y" does not work. > > >>> import fractions > >>> x = 12345 * 10**1000 > >>> y = 765 * 10**1000 >

Re: long int computations

2010-05-03 Thread Peter Pearson
On Mon, 03 May 2010 17:30:03 +0200, Peter Otten <__pete...@web.de> wrote: > Victor Eijkhout wrote: > >> I have two long ints, both too long to convert to float, but their ratio >> is something reasonable. How can I compute that? The obvious "(1.*x)/y" >> does not work. > import fractions

Re: long int computations

2010-05-03 Thread Dave Angel
Victor Eijkhout wrote: I have two long ints, both too long to convert to float, but their ratio is something reasonable. How can I compute that? The obvious "(1.*x)/y" does not work. Victor. You don't make clear what you mean by "too long to convert to float." Do you mean can't convert exa

Re: long int computations

2010-05-03 Thread Jerry Hill
On Mon, May 3, 2010 at 11:17 AM, Victor Eijkhout wrote: > I have two long ints, both too long to convert to float, but their ratio > is something reasonable. How can I compute that? The obvious "(1.*x)/y" > does not work. You didn't say what version of python you were using, but this seems to wor

Re: long int computations

2010-05-03 Thread Peter Otten
Victor Eijkhout wrote: > I have two long ints, both too long to convert to float, but their ratio > is something reasonable. How can I compute that? The obvious "(1.*x)/y" > does not work. >>> import fractions >>> x = 12345 * 10**1000 >>> y = 765 * 10**1000 >>> float(x) Traceback (most recent cal

long int computations

2010-05-03 Thread Victor Eijkhout
I have two long ints, both too long to convert to float, but their ratio is something reasonable. How can I compute that? The obvious "(1.*x)/y" does not work. Victor. -- Victor Eijkhout -- eijkhout at tacc utexas edu -- http://mail.python.org/mailman/listinfo/python-list