En Sat, 27 Dec 2008 22:02:51 -0200, <jerry.carl...@gmail.com> escribió:

I have been looking for a Python module with math functions that would
both eat and spit Decimals. The standard math module eats Decimals
allright but spits floats... herefore exp(sin(Decimal())) produces exp
() of a float :-(

Which math functions? ln, log10, exp, sqrt already exist as methods of Decimal instances. At the end of the Decimal docs there are a few examples, including computing sin and cos (but apparently they naïvely use a McLaurin series like you noticed in other module). There is a way to convert a float into a Decimal object with no loss in precision, see the FAQ (using float.as_integer_ratio(), I think such function was implemented for exactly this use case) So you might convert to float, operate, and go back -- if the precision of "double" operands is enough for you.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to