finding out the precision of floats

Bart Ogryczak B.Ogryczak at gmail.com
Wed Feb 28 12:48:59 EST 2007


On Feb 28, 6:34 pm, "Arnaud Delobelle" <arno... at googlemail.com> wrote:
> > 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.

Without divisions?

> 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.

How about (1.0/3.0)*3.0 == 1.0? That doesn't need to be True?

> Please do not make the assumption that I have chosen to use a decimal
> type without some careful consideration.

Well, you didn't indicate this before. Anyway, in that case efficiency
has no impact at all, so you might as well use Decimal.





More information about the Python-list mailing list