On Mon, Oct 12, 2009 at 4:15 PM, Anand Balachandran Pillai <abpil...@gmail.com> wrote: > > > On Mon, Oct 12, 2009 at 4:08 PM, Rajeev J Sebastian > <rajeev.sebast...@gmail.com> wrote: >> >> >> > I am not however a fan of the decimal module since it uses strings as >> > the >> > base type. >> >> What else should it use then ? > > Nothing. It should be taken care of in the float implementation > without needing another module to fix it. > > Having to convert my float to a string to get a correct representation of > it > is indeed awkward. > >>>> Decimal(1.0) > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "/usr/lib64/python2.5/decimal.py", line 578, in __new__ > "First convert the float to a string") > TypeError: Cannot convert float to Decimal. First convert the float to a > string > > A strange error, but I agree it is required for the module to work...! > > Does numpy take care of these issues ?
The error message is wrong not the implementation. Floating point representation is not exact. For example look at 1.1: >>> 1.1 1.1000000000000001 If you say Decimal(1.1) should it take it as 1.1 or 1.1000000000000001? _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers