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
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__
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
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.
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
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
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.
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
>
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
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
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
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
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
13 matches
Mail list logo