On Fri, 26 Oct 2007 16:29:34 -0700, jimmy.musselwhite wrote: > On Oct 26, 6:56 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote: >> On 10/26/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> >> 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.
Because this is homework, I'm not going to give you the answer. But I will give you *almost* the answer: (A*T*C*G)**200000 = ?.03?10875*10**-51?194 Some of the digits in the above have been deliberately changed to question marks, to keep you honest. > 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". Hint: If we multiply A*T*C*G, we get 0.002625. That's the same as 0.2625 with a (negative) scale factor of 2. Another hint: for calculations of this nature, you can't rely on floating point because it isn't exact. You need to do everything in integer maths. A third hint: don't re-scale the product too often. Enough clues? -- Steven. -- http://mail.python.org/mailman/listinfo/python-list