Going past the float size limits?
Hendrik van Rooyen
mail at microcorp.co.za
Sun Oct 28 03:44:17 EDT 2007
"Steven D'Aprano" <stev....e.com.au> wrote:
> Calculating numbers like 10**520000 or its reciprocal is also a very good
> exercise in programming. Anyone can write a program to multiply two
> floating point numbers together and get a moderately accurate answer:
>
> product = X*Y # yawn
>
> But multiplying 200,000 floating point numbers together and getting an
> accurate answer somewhere near 10**-520000 requires the programmer to
> actually think about what they're doing. You can't just say:
>
> A,T,C,G = (0.35, 0.30, 0.25, 0.10)
> product = map(operator.mul, [A*T*C*G]*200000)
>
> and expect to get anywhere.
>
> Despite my fear that this is a stupid attempt by the Original Poster's
> professor to quantify the old saw about evolution being impossible
> ("...blah blah blah hurricane in a junk yard blah blah Concorde blah blah
> blah..."), I really like this homework question.
yes it got me going too - and I even learned about the gmpy stuff - so it was
a bit of a Good Thing...
- Hendrik
More information about the Python-list
mailing list