Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Going past the float size limits?

Reply
Thread Tools

Going past the float size limits?

 
 
jimmy.musselwhite@gmail.com
Guest
Posts: n/a
 
      10-26-2007
Hello all
It would be great if I could make a number that can go beyond current
size limitations. Is there any sort of external library that can have
infinitely huge numbers? Way way way way beyond say 5x10^350 or
whatever it is?

I'm hitting that "inf" boundary rather fast and I can't seem to work
around it.

Thanks!

 
Reply With Quote
 
 
 
 
Diez B. Roggisch
Guest
Posts: n/a
 
      10-26-2007
schrieb:
> Hello all
> It would be great if I could make a number that can go beyond current
> size limitations. Is there any sort of external library that can have
> infinitely huge numbers? Way way way way beyond say 5x10^350 or
> whatever it is?
>
> I'm hitting that "inf" boundary rather fast and I can't seem to work
> around it.


http://gmpy.sourceforge.net/

Diez
 
Reply With Quote
 
 
 
 
Chris Mellon
Guest
Posts: n/a
 
      10-26-2007
On 10/26/07, <> wrote:
> Hello all
> It would be great if I could make a number that can go beyond current
> size limitations. Is there any sort of external library that can have
> infinitely huge numbers? Way way way way beyond say 5x10^350 or
> whatever it is?
>
> I'm hitting that "inf" boundary rather fast and I can't seem to work
> around it.
>


What in the world are you trying to count?
 
Reply With Quote
 
Guilherme Polo
Guest
Posts: n/a
 
      10-26-2007
2007/10/26, <>:
> Hello all
> It would be great if I could make a number that can go beyond current
> size limitations. Is there any sort of external library that can have
> infinitely huge numbers? Way way way way beyond say 5x10^350 or
> whatever it is?


Check the decimal module

>
> I'm hitting that "inf" boundary rather fast and I can't seem to work
> around it.
>
> Thanks!
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



--
-- Guilherme H. Polo Goncalves
 
Reply With Quote
 
J. Cliff Dyer
Guest
Posts: n/a
 
      10-26-2007
wrote:
> Hello all
> It would be great if I could make a number that can go beyond current
> size limitations. Is there any sort of external library that can have
> infinitely huge numbers? Way way way way beyond say 5x10^350 or
> whatever it is?
>
> I'm hitting that "inf" boundary rather fast and I can't seem to work
> around it.
>
> Thanks!
>
>

hmm.

Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:0 [MSC v.1310 32 bit
(Intel)] on win32
<snip>
>>> 5 * (10 ** 700)

50000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 000000000000000
00000000000000000000000000000000000000000000000000 0L


Do you really need more than 700 places of precision? Once your numbers
are that large, surely you can use integer math, right? (FYI 5 * (10 **
10000) works just as well.

Cheers,
Cliff
 
Reply With Quote
 
Matt McCredie
Guest
Posts: n/a
 
      10-26-2007
> It would be great if I could make a number that can go beyond current
> size limitations. Is there any sort of external library that can have
> infinitely huge numbers? Way way way way beyond say 5x10^350 or
> whatever it is?
>
> I'm hitting that "inf" boundary rather fast and I can't seem to work
> around it.



You have a couple of options.
1. Use long if that is appropriate for your data, they can be as large
as you want (eventually you will reach memory constraints, but that
isn't likely)
2. There is a decimal type, which is based on long (I think) and can
have a decimal portion.

to use longs:
x = 5 * 10**350

to use decimal:
import decimal
x = decimal.Decimal("5e350")

You will probably want to read up on the decimal module.

Matt
 
Reply With Quote
 
jimmy.musselwhite@gmail.com
Guest
Posts: n/a
 
      10-26-2007
On Oct 26, 6:56 pm, "Chris Mellon" <arka...@gmail.com> wrote:
> On 10/26/07, jimmy.musselwh...@gmail.com <jimmy.musselwh...@gmail.com> wrote:
>
> > Hello all
> > It would be great if I could make a number that can go beyond current
> > size limitations. Is there any sort of external library that can have
> > infinitely huge numbers? Way way way way beyond say 5x10^350 or
> > whatever it is?

>
> > I'm hitting that "inf" boundary rather fast and I can't seem to work
> > around it.

>
> What in the world are you trying to count?


The calculation looks like this

A = 0.35
T = 0.30
C = 0.25
G = 0.10

and then I basically continually multiply those numbers together. I
need to do it like 200,000+ times but that's nuts. I can't even do it
1000 times or the number rounds off to 0.0. I tried taking the inverse
of these numbers as I go but then it just shoots up to "inf".

 
Reply With Quote
 
Hrvoje Niksic
Guest
Posts: n/a
 
      10-26-2007
writes:

> The calculation looks like this
>
> A = 0.35
> T = 0.30
> C = 0.25
> G = 0.10
>
> and then I basically continually multiply those numbers together. I
> need to do it like 200,000+ times but that's nuts. I can't even do it
> 1000 times or the number rounds off to 0.0. I tried taking the inverse
> of these numbers as I go but then it just shoots up to "inf".


>>> import gmpy
>>> A = gmpy.mpf('0.35')
>>> B = gmpy.mpf('0.30')
>>> C = gmpy.mpf('0.25')
>>> D = gmpy.mpf('0.10')
>>> result = gmpy.mpf(1)
>>> for n in xrange(200000):

.... result *= A
.... result *= B
.... result *= C
.... result *= D
....
>>> result

mpf('7.27023409768722186651e-516175')

It's reasonably fast, too. The above loop took a fraction of a second
to run on an oldish computer.
 
Reply With Quote
 
Grant Edwards
Guest
Posts: n/a
 
      10-27-2007
On 2007-10-26, <> wrote:

>> What in the world are you trying to count?

>
> The calculation looks like this
>
> A = 0.35
> T = 0.30
> C = 0.25
> G = 0.10


The bases in DNA?

> and then I basically continually multiply those numbers together. I
> need to do it like 200,000+ times but that's nuts.


Exactly. It sure looks like what you're doing is nuts.

> I can't even do it 1000 times or the number rounds off to 0.0.
> I tried taking the inverse of these numbers as I go but then
> it just shoots up to "inf".


Can you explain what it is you're trying to calculate?

--
Grant Edwards


 
Reply With Quote
 
=?utf-8?b?U3TDqXBoYW5l?= Larouche
Guest
Posts: n/a
 
      10-27-2007
<jimmy.musselwhite <at> gmail.com> writes:

> The calculation looks like this
>
> A = 0.35
> T = 0.30
> C = 0.25
> G = 0.10
>
> and then I basically continually multiply those numbers together. I
> need to do it like 200,000+ times but that's nuts. I can't even do it
> 1000 times or the number rounds off to 0.0. I tried taking the inverse
> of these numbers as I go but then it just shoots up to "inf".


I suggest you add the logarithm of those numbers.

Stéphane

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
float to string to float, with first float == second float Carsten Fuchs C++ 45 10-08-2009 09:47 AM
Going past the float size limits? Fredrik Johansson Python 0 10-28-2007 09:50 PM
Win XP Home not going past welcome screen Vic Computer Support 1 01-16-2006 04:16 PM
Table going past width boundries Geoff Robinson HTML 4 10-26-2004 06:53 PM
Re: float->byte->float is same with original float image. why float->ubyte->float is different??? bd C Programming 0 07-07-2003 12:09 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57