[Python-Dev] RE: Adding decimal (aka FixedPoint) numbers to Python

Greg Ewing greg@cosc.canterbury.ac.nz
Wed, 18 Dec 2002 12:41:54 +1300 (NZDT)


Tim Peters <tim.one@comcast.net>:

> If you want to presume that users are idiots as well as simply
> ignorant, then fixed_point_decimal() is what you want.
> "decimal" leaves out the vital distinction between fixed and floating
> semantics, which is more important to "good to the last penny" results than
> the distinction between binary and decimal.

I don't agree with that. The first and foremost reason why a
penny-adder will get the right result with this type whereas he
wouldn't with a Python float is that it's decimal and not
binary. Floatness only becomes an issue when the number of dollars
he's adding up becomes large enough. If it doesn't, he could do the
same calculation on his floating-point-decimal calculator and get the
right answer, too.

So, no matter what it's called -- fixed, decimal, or even
fixed_decimal, he's not going to be able to guess that he needs to use
it, he's going to have to be told.

Given that, there's no point in worrying about what naive users may or
may not think when deciding on a name for this. And I think a name
should be chosen which reflects what it is about this type that makes
it useful. I agree that the non-floatness is important, but it seems
to me that the decimalness is at least as important, too.

You're going to have to face this issue if you ever want to add a
floating decimal type as well. If the fixed decimal type is just
called "fixed", what are you going to call a floating decimal? You
can't just call it "float", because we've already got one of those!

Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg@cosc.canterbury.ac.nz	   +--------------------------------------+