Message180913
Sorry, I take that back. The behaviour is correct: ROUND_UP rounds away from zero; ROUND_DOWN towards zero. For rounding towards +/- infinity, you want ROUND_CEILING and ROUND_FLOOR:
Python 2.7.3 |EPD 7.3-1 (32-bit)| (default, Apr 12 2012, 11:28:34)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "credits", "demo" or "enthought" for more information.
>>> from decimal import *
>>> a = Decimal("-3.86")
>>> a.quantize(Decimal(".1"), ROUND_CEILING)
Decimal('-3.8')
>>> a.quantize(Decimal(".1"), ROUND_FLOOR)
Decimal('-3.9')
Closing as invalid. |
|
Date |
User |
Action |
Args |
2013-01-29 16:18:38 | mark.dickinson | set | recipients:
+ mark.dickinson, Hakim.Taklanti |
2013-01-29 16:18:38 | mark.dickinson | set | messageid: <1359476318.48.0.167982889405.issue17072@psf.upfronthosting.co.za> |
2013-01-29 16:18:38 | mark.dickinson | link | issue17072 messages |
2013-01-29 16:18:38 | mark.dickinson | create | |
|