Alternative to Decimal type

Frank Millman frank at chagford.com
Mon Jun 9 10:21:28 EDT 2008


On Jun 9, 4:06 pm, Frank Millman <fr... at chagford.com> 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.



More information about the Python-list mailing list