prePEP: Decimal data type

Batista, Facundo FBatista at uniFON.com.ar
Tue Nov 4 12:34:28 EST 2003


John Roth wrote:

#- Why is ANSI 274 significant? The reason I ask this is that this is
#- a ***floating point*** standard, and I don't think that we 
#- particularly
#- care for decimal floating point.
#- 
#- Floating point presumes limited precision. In other words, 
#- if the actual
#- number (exclusive of the location of the decimal point) gets 
#- too large,
#- the least significant part is ... thrown away. I don't want that.

If what you're saying is that, with a precision of 5...

45     --> 00045E+0
45321  --> 45321E+0
453211 --> 45321E+1

...you're right. 

You may not like it, but that what it is: I'm following the General Decimal
Arithmetic Specification, see Mike Cowlishaw's work at
http://www2.hursley.ibm.com/decimal/.




#- The "other type" should be handled in the same way the decimal()
#- constructor would handle it.

¿Are you saying that if Decimal('45') is valid, Decimal('45') + '25' should
also be valid? Mmm... ugly, ugly.



#- > 1. The syntax should be ``Decimal(value)``.
#- 
#- Lower case: "decimal(value, [scale factor])"

I thought that first letter in uppercase was good style for class names.



#- > 4. The Context must be omnipresent, meaning that changes 
#- to it affects all
#- >    the current and future Decimal instances.
#- 
#- No. The context should be selectable for the particular 
#- usage. That is,
#- it should be possible to have several different contexts in 
#- play at one
#- time in an application.

The concept of context is a "configuration place" surrounding the instances.


What you propose?

	- the configuration (precision, flags, etc) is on by-instance basis
	- you have different contexts, and a group of instances with each
context.


#- > 9. To have different kinds of rounding; you can choose the 
#- algorithm
#- through
#- >    context:
#- > ...
#- I think this is simply too much. I'd rather have a round() 
#- method that
#- takes a *small* number of standard options, and otherwise takes a
#- function to do the rounding.

Again, this is the General Decimal Arithmetic Specification.


.	Facundo





More information about the Python-list mailing list