Re: Alternative to Decimal type

2008-06-12 Thread Frank Millman
On Jun 11, 11:48 am, Frank Millman [EMAIL PROTECTED] wrote: Thanks to all for the various replies. They have all helped me to refine my ideas on the subject. These are my latest thoughts. [snip] My main concern is that my approach may be naive, and that I will run into situations that I have

Re: Alternative to Decimal type

2008-06-12 Thread Grant Edwards
On 2008-06-12, Dennis Lee Bieber [EMAIL PROTECTED] wrote: If you were to follow the footsteps of COBOL, you'd be using BCD internally, with a special code to represent the decimal point (and maybe, to save space, the sign too) Old mainframes had instructions to work with packed BCD as a

Re: Alternative to Decimal type

2008-06-11 Thread Frank Millman
Thanks to all for the various replies. They have all helped me to refine my ideas on the subject. These are my latest thoughts. Firstly, the Decimal type exists, it clearly works well, it is written by people much cleverer than me, so I would need a good reason not to use it. Speed could be a

Re: Alternative to Decimal type

2008-06-11 Thread Ethan Furman
Frank Millman wrote: Thanks to all for the various replies. They have all helped me to refine my ideas on the subject. These are my latest thoughts. Firstly, the Decimal type exists, it clearly works well, it is written by people much cleverer than me, so I would need a good reason not to use

Re: Alternative to Decimal type

2008-06-11 Thread Frank Millman
On Jun 11, 4:39 pm, Ethan Furman [EMAIL PROTECTED] wrote: Frank Millman wrote: Thanks to all for the various replies. They have all helped me to refine my ideas on the subject. These are my latest thoughts. Out of curiosity, what is the purpose of these numbers?  Do they represent money,

Re: Alternative to Decimal type

2008-06-11 Thread Nick Craig-Wood
Frank Millman [EMAIL PROTECTED] wrote: Thanks to all for the various replies. They have all helped me to refine my ideas on the subject. These are my latest thoughts. Firstly, the Decimal type exists, it clearly works well, it is written by people much cleverer than me, so I would need a

Re: Alternative to Decimal type

2008-06-11 Thread Terry Reedy
Frank Millman [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | Thanks to all for the various replies. They have all helped me to | refine my ideas on the subject. These are my latest thoughts. | | Firstly, the Decimal type exists, it clearly works well, it is written | by people much

Re: Alternative to Decimal type

2008-06-11 Thread Aahz
In article [EMAIL PROTECTED], Frank Millman [EMAIL PROTECTED] wrote: My approach is based on expressing a decimal number as a combination of an integer and a scale, where scale means the number of digits to the right of the decimal point. You should probably use one written by an expert:

Re: Alternative to Decimal type

2008-06-10 Thread Ethan Furman
Mel wrote: Frank Millman wrote: Hi all I have a standard requirement for a 'decimal' type, to instantiate and manipulate numeric data that is stored in a database. I came up with a solution long before the introduction of the Decimal type, which has been working well for me. I know the

Alternative to Decimal type

2008-06-09 Thread Frank Millman
Hi all I have a standard requirement for a 'decimal' type, to instantiate and manipulate numeric data that is stored in a database. I came up with a solution long before the introduction of the Decimal type, which has been working well for me. I know the 'scale' (number of decimal places) of the

Re: Alternative to Decimal type

2008-06-09 Thread Paul Hankin
On Jun 9, 5:11 pm, Frank Millman [EMAIL PROTECTED] wrote: I have a standard requirement for a 'decimal' type, to instantiate and manipulate numeric data that is stored in a database. I came up with a solution long before the introduction of the Decimal type, which has been working well for me.

Re: Alternative to Decimal type

2008-06-09 Thread Frank Millman
On Jun 9, 10:54 am, Paul Hankin [EMAIL PROTECTED] wrote: Hi Frank, I don't know why you think Decimal is complicated: it has some advanced features, but for what you seem to be doing it should be easy to replace your 'Number' with it. In fact, it makes things simpler since you don't have to

Re: Alternative to Decimal type

2008-06-09 Thread Mel
Frank Millman wrote: Hi all I have a standard requirement for a 'decimal' type, to instantiate and manipulate numeric data that is stored in a database. I came up with a solution long before the introduction of the Decimal type, which has been working well for me. I know the 'scale'

Re: Alternative to Decimal type

2008-06-09 Thread Frank Millman
On Jun 9, 3:07 pm, Mel [EMAIL PROTECTED] wrote: Frank Millman wrote: class Number(object):     def __init__(self,value,scale):         self.factor = 10.0**scale         if isinstance(value,Number):             value = value.value / value.factor I think this could lead to trouble.  

Re: Alternative to Decimal type

2008-06-09 Thread Frank Millman
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

Re: Alternative to Decimal type

2008-06-09 Thread Diez B. Roggisch
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