On 04:54 pm, guido at python.org wrote: >On Jan 4, 2008 10:16 PM, <glyph at divmod.com> wrote: >>Having other rounding methods *available*, though, would be neat. The >>only application I've ever worked on where I cared about the >>difference, >>the user had to select it (since accounting requirements differ by >>jurisdiction and, apparently, by bank preference). Having a standard >>way to express this (especially if it worked across different numeric >>types, but perhaps I digress) would be pleasant. Implementing >>stochastic rounding and banker's rounding oneself, while not exactly >>hard, is a drag. > >The decimal module already supports rounding modes in its context. For >other types, perhaps converting to decimal might be good enough? Yes, that's the right thing to do. I had missed it. After all it is decimal rounding I want, and any financial applications I'm going to write these days are using decimals already for all the usual reasons. At first I didn't realize why I'd missed this feature. While the rounding *modes* are well documented, though, after 20 minutes of reading documentation I still haven't found a method or function that simply rounds a decimal to a given significant digit. Is there one, should there be one, or is the user simply meant to use Context.quantize with appropriate arguments?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4