[Python-Dev] Decimal data type issues (original) (raw)

Edward Loper edloper at gradient.cis.upenn.edu
Thu Apr 15 12:49:51 EDT 2004


#- > #- > DEFAULTMAXEXPONENT = 999999999 #- > #- > DEFAULTMINEXPONENT = -999999999 #- > #- > ABSOLUTEMAXEXP = 999999999 #- > #- > ABSOLUTEMINEXP = -999999999 #- #- I can think of at least one real use for exponents outside #- this range: #- probabilities. E.g., if I'm using probabilistic models to estimate

So you need a number smaller than 10**(-999999999)?

Not often. And of course, "need" might be a bit strong, since I can use other tricks (logs & renormalization) to avoid underflow. But yes, I can imagine cases where I would get underflow using naive algorithms. E.g., if I'm looking at probabilities for 1 billion words of text (computational linguists are starting to use corpora of this size), and for some reason I want to do language modelling on it, I could end up with numbers on the order of (1e-20)(1,000,000,000). I.e., 10(-20,000,000,000).

On the other hand, I can't think of a use, off hand, of calculating the probability of a billion word string of text. But I just wanted to point out that there may be cases where extremely large/small numbers can be useful; and as computers get more powerful and space gets cheaper, the numbers people use will tend to grow in size.

I understand the argument that this may help catch errors, but I just don't think it will catch many errors. How many people would have errors that would have been caught if long had an absolute min/max?

-Edward



More information about the Python-Dev mailing list