From: Christopher S. <csi...@gm...> - 2008-02-08 19:57:10
|
On Friday 08 February 2008 13:03:42 Oleg Broytmann wrote: > I don't remember Decimal can do conversion to string and back from > string preserving precision. Are you talking about converting to > floating-point string? str(Decimal("1.1")) => '1.1'? I don't know if the > conversion preserves all digits. But if it does - that's the way to go, of > course. http://www.python.org/dev/peps/pep-0327/#documentation PEP 327 says that str(Decimal()) implements the to-scientific-string function required by IBM's Decimal Arithmetic Specification. http://www2.hursley.ibm.com/decimal/daconvs.html#reftostr Unless the developers grossly misimplemented the spec, then the coefficient will contain all significant digits. An example of this usage is included in the Python Library Reference for the module. http://docs.python.org/lib/decimal-tutorial.html > > Wouldn't > > that just be about 4 lines of code? > > Plus tests, plus at least a line in News.txt, plus thinking if it breaks > something for those who now use floats with DecimalCol. I wouldn't know how to write a test. As for the last, I'm trying to think of how improved accuracy would screw up somebody's code. It could be a problem if SQLObject no longer works with their existing sqlite databases, but I think that ought to be solveable. It could be a problem if they want to access their sqlite databases with other tools outside of SQLObject. > > You'll have to pardon me. I don't mind doing work, but looking at the > > SQLObject source code makes my head spin a little bit. > > Is it really that bad? I'm just a novice programmer, and you guys do some reasonably sophisticated stuff in there. I can't even figure out whether SODecimalCol objects actually have attributes representing the values persisted in the database, and if so what they're called. cs |