penny distribution
Batista, Facundo
FBatista at uniFON.com.ar
Fri Nov 7 11:53:48 EST 2003
austin at smartobject.biz wrote:
#- Let me try another way of saying this. A number with a small number
#- of decimal places is equivalent to an integer, as was pointed out
#- before. People don't expect division of integers, or multiplication
#- of integers by reals (and I still think the former is a subset of the
#- latter) to yield exact integer answers. There will obviously be some
#- rounding involved, although some people might want to specify exactly
#- how that rounding takes place. However, most people expect addition
#- and subtraction of integers to yield exact integer answers. An
#- itemized invoice that contains percentage taxation or discounting
#- (i.e., most invoices I've seen) enforces some sort of
#- distributive law
#- on inexact multiplication and exact addition. A program that
#- generates such an invoice must have some way of adjusting the
#- multiplication to safisfy the distributive law. Invariably, attempts
#- to adjust addition instead make customers very unhappy.
Get your point. But which side do you adjust?
I think something like this is not the behaviour expected for a + or a *.
Of course, your point is still valid, but I think that the operation is not
the place to address it.
It's the same with .divideByN: a method that do that, because the standard
division don't. And you don't modify the standard division to return
something like this:
>>> Decimal(5) / 3
(1.66, 1.67, 1.67)
You just don't.
. Facundo
More information about the Python-list
mailing list