Frank Millman wrote: > On Jun 9, 4:06 pm, Frank Millman <[EMAIL PROTECTED]> wrote: >> >> Thanks for the reply, Mel. I don't quite understand what you mean. > > As so often happens, after I sent my reply I re-read your post and I > think I understand what you are getting at. > > One problem with my approach is that I am truncating the result down > to the desired scale factor every time I create a new instance. This > could result in a loss of precision if I chain a series of instances > together in a calculation. I think that what you are suggesting avoids > this problem. > > I will read your message again carefully. I think it will lead to a > rethink of my approach. > > Thanks again > > Frank > > P.S. Despite my earlier reply to Paul, I have not abandoned the idea > of using my Number class as opposed to the standard Decimal class. > > I did a simple test of creating two instances and adding them > together, using both methods, and timing them. Decimal came out 6 > times slower than Number. > > Is that important? Don't know, but it might be.
It is because it uses arbitrary precision integer literals instead of ieee floats. It pays this price so you get decimal rounding errors instead of binary. Yet rounding errors you get... If you are in money calculations with your Number-class - you certainly want Decimal instead. If all you want is auto-rounding... then you might not care. Diez -- http://mail.python.org/mailman/listinfo/python-list