[Python-Dev] Re: Re: Decimal type question [Prothon]

Mark Hahn mark at prothon.org
Tue Aug 10 05:24:00 CEST 2004


On Mon, 9 Aug 2004 10:48:44 -0700, Andrew P. Lentvorski, Jr. wrote:

> On Aug 9, 2004, at 10:29 AM, Mark Hahn wrote:
> 
>> Forgive me if I'm being a pest, but no one has commented on the real 
>> reason
>> I asked the question.  What does everyone think of the idea of having 
>> these
>> three built-in numeric types?
>>
>> 1) An Int implemented with infinite precision integer (Python Longs) 
>> with
>> the constant/__str__ form of +-NN such as 0, -123, 173_394, etc.
>>
>> 2) A Decimal implemented with the .Net decimal float (or the IBM 
>> decimal if
>> the .Net decimal sucks too much) with the constant/__str__ form of 
>> +-NN.NN
>> such as 0.0, -123.0, 173_394.0, 173394.912786765, etc.
>>
>> 3) A binary Float implemented with the hardware floating point with the
>> constant/__str__ form of +-NN.NN+-eNN such as 0e0, -123e0, 173.39e+3,
>> 2.35e-78, etc.
> 
> Be careful defining string representations of numbers.  It is a 
> non-trivial
> problem to adhere to the correct internationalization standards.
> 
> Forgive me if I'm being dense, but don't we already have 1 & 3 as built
> in types?

There is no "we".  This thread is about Prothon which has nothing yet since
it hasn't ever been released.  Your feedback is still relevant and helpful
though.

> 2 is unlikely to be a builtin until folks get some experience using the
> Decimal module.  Yes, the .Net Decimal sucks.
> 
> In addition, the desired evolution of Python seems to be replacing the
> binary floating point as the default floating point type with the
> decimal floating point type by default rather than growing another
> builtin numeric type.  This is obviously contingent upon the Decimal 
> module
> getting some real-life use as well as it getting some speed improvements
> in the future.
> 
>> There would be no automatic conversion except the / operator would 
>> convert
>> from Int to Decimal
> 
> Int goes to the default type of float (which is currently binary FP) 
> already
> upon using the / operator.
> 
>>  and the Math module would convert Int and Decimal
>> values to Float for almost all functions (except simple ones like abs, 
>> min,
>> max).
> 
> This is not necessarily a good idea.  Exponentials are very useful in
> financial situations and want to be decimals, not binary floats, in 
> those
> cases.

Good point.



More information about the Python-Dev mailing list