On 28 Feb, 11:38, "Bart Ogryczak" <[EMAIL PROTECTED]> wrote: > On Feb 27, 7:58 pm, "Arnaud Delobelle" <[EMAIL PROTECTED]> wrote: > > This is one of the reasons (by no means the main) why I decided to > > write my own class. > > Why not GMP?
I need decimals. > My point is, that neither is Decimal. It doesn't solve the problem, > creating additional problem with efficiency. > > > >>> 0.1+0.1+0.1==0.3 > > False > > >>> 3*0.1==0.3 > > > False > > > Decimals will behave better in this case. > > Decimal will work fine as long as you deal only with decimal numbers > and the most basic arithmetic. Any rational number with base that is > not power of 10, or any irrational number won't have an exact > representation. My problem is precisely to represent rational numbers whose denominator is a power of 10 (aka decimals) accurately. > So as long as you're dealing with something like > invoices, Decimal does just fine. When you start real calculations, > not only scientific, but even financial ones[1], it doesn't do any > better then binary float, and it's bloody slow. I'm not doing 'real world' calcultations, I'm making an app to help teach children maths. I need numerical values that behave well as decimals. I also need them to have an arbitrary number of significant figures. Floats are great but they won't help me with either. Amongst other things, I need 3.0*0.1==0.3 to be True. Please do not make the assumption that I have chosen to use a decimal type without some careful consideration. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list