summaryrefslogtreecommitdiffstats
path: root/Lib/decimal.py
Commit message (Collapse)AuthorAgeFilesLines
* Issue #8567: Fix incorrect precedence of signals in Decimal module.Mark Dickinson2010-05-041-43/+83
| | | | | | | | | | When a Decimal operation raises multiple signals and more than one of those signals is trapped, the specification determines the order in which the signals should be handled. In many cases this order wasn't being followed, leading to the wrong Python exception being raised. This commit fixes those cases, and adds extra tests. The tests are only enabled when EXTENDEDERRORTESTS is True, since they involve rerunning each Decimal testcase several times.
* Issue 8257: Decimal constructor to accept float.Raymond Hettinger2010-04-021-2/+6
|
* Issue #7279: Make Decimal('nan') hashable. Decimal('snan') remains unhashable.Mark Dickinson2010-04-021-4/+20
| | | | | | Also rewrite the Decimal __hash__ method so that it doesn't rely on float('inf') being valid: float('inf') could raise an exception on platforms not using IEEE 754 arithmetic.
* Issue #7279: Make comparisons involving a Decimal sNaN signal InvalidOperation.Mark Dickinson2010-04-021-6/+9
|
* Issue #2531: Make float-to-decimal comparisons return correct results.Mark Dickinson2010-04-021-13/+25
| | | | | | | Float to decimal comparison operations now return a result based on the numeric values of the operands. Decimal.__hash__ has also been fixed so that Decimal and float values that compare equal have equal hash value.
* Doctest fixes for decimal.py: add an integer-argument doctest for ↵Mark Dickinson2010-02-181-18/+20
| | | | logical_invert; don't use integer literals with a leading zero.
* Issue #7633: Context method in the decimal module (with the exceptionMark Dickinson2010-02-181-18/+340
| | | | | | of the 'canonical' and 'is_canonical' methods) now consistently accept integer arguments wherever a Decimal instance is accepted. Thanks Juan José Conti for the patch.
* compare types with is not ==Benjamin Peterson2010-01-251-2/+2
|
* mention from_float() in error messageBenjamin Peterson2010-01-251-2/+2
|
* Add missing docstring for Context.divmod. Thanks Juan José Conti.Mark Dickinson2010-01-061-0/+7
|
* Issue #7233: Fix Decimal.shift and Decimal.rotate methods forMark Dickinson2009-10-291-8/+10
| | | | | arguments with more digits than the current context precision. Bug reported by Stefan Krah.
* Issue #7233: A number of two-argument Decimal methods were failing toMark Dickinson2009-10-291-1/+20
| | | | accept ints and longs for the second argument.
* Issue #7099: Decimal.is_normal should return True for all nonzeroMark Dickinson2009-10-201-1/+1
| | | | finite non-subnormal values, even those with exponent > Emax.
* Issue #7048: logb should round its result when that result doesn't fitMark Dickinson2009-10-071-1/+2
| | | | | | into the available precision. (Tests for this change are included in the most recent set of testcases from the Decimal Specification site; those testcases will be updated shortly.)
* Issue #6857: Fix Decimal formatting to be consistent with existing floatMark Dickinson2009-09-081-1/+4
| | | | formatting: both are now right-aligned by default.
* #Issue 6795: Fix infinite recursion in long(Decimal('nan')); change ↵Mark Dickinson2009-09-071-3/+2
| | | | int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext.
* Issue #6850: Fix bug in Decimal._parse_format_specifier for formatsMark Dickinson2009-09-071-1/+1
| | | | with no type specifier.
* Issue #6794: Fix handling of NaNs in Decimal.compare_total andMark Dickinson2009-08-281-2/+5
| | | | Decimal.compare_total_mag.
* Issue #6595: Allow Decimal constructor to accept non-European decimalMark Dickinson2009-08-021-17/+10
| | | | | digits, as recommended by the specification. (Backport of r74279 from py3k.)
* Update spec version number.Raymond Hettinger2009-04-271-1/+1
|
* Fix bug in _insert_thousands_sep: too much zero padding could beMark Dickinson2009-03-181-2/+1
| | | | added for 'n' formats with non-repeating thousands-separator.
* Issue #2110: Add support for thousands separator and 'n' format specifierMark Dickinson2009-03-171-83/+202
| | | | to Decimal __format__ method.
* Fix bug in Decimal __format__ method that swapped left and rightMark Dickinson2009-03-171-2/+2
| | | | alignment.
* Add a version tag to the decimal module.Raymond Hettinger2009-03-101-0/+2
|
* Register decimals as numbers.NumberRaymond Hettinger2009-02-031-0/+7
|
* Remove uses of cmp from the decimal module.Mark Dickinson2009-01-251-3/+15
|
* More Python 2.3 compatibility fixes for decimal.py.Mark Dickinson2009-01-041-4/+4
|
* Fix Decimal.from_float to use valid Python 2.3 syntax, as perMark Dickinson2009-01-041-3/+11
| | | | | | comments at top of decimal.py. (But note that the from_float method itself with still not be usable before Python 2.7.) See issue 4796 for discussion.
* Reapply r68191.Raymond Hettinger2009-01-031-56/+56
|
* Issue 4796: Add from_float methods to the decimal module.Raymond Hettinger2009-01-031-56/+106
|
* Issue #4812: further renaming of internal Decimal constants, for clarity.Mark Dickinson2009-01-031-56/+56
|
* Issue #4812: add missing underscore prefix to some internal-use-onlyMark Dickinson2009-01-021-63/+63
| | | | constants in the decimal module. (Dec_0 becomes _Dec_0, etc.)
* Issue #4084: Fix max, min, max_mag and min_mag Decimal methods toFacundo Batista2008-12-111-16/+16
| | | | | | give correct results in the case where one argument is a quiet NaN and the other is a finite number that requires rounding. Thanks Mark Dickinson.
* Fix:Neal Norwitz2008-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * crashes on memory allocation failure found with failmalloc * memory leaks found with valgrind * compiler warnings in opt mode which would lead to invalid memory reads * problem using wrong name in decimal module reported by pychecker Update the valgrind suppressions file with new leaks that are small/one-time leaks we don't care about (ie, they are too hard to fix). TBR=barry TESTED=./python -E -tt ./Lib/test/regrtest.py -uall (both debug and opt modes) in opt mode: valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \ ./python -E -tt ./Lib/test/regrtest.py -uall,-bsddb,-compiler \ -x test_logging test_ssl test_multiprocessing valgrind -q --leak-check=yes --suppressions=Misc/valgrind-python.supp \ ./python -E -tt ./Lib/test/regrtest.py test_multiprocessing for i in `seq 1 4000` ; do LD_PRELOAD=~/local/lib/libfailmalloc.so FAILMALLOC_INTERVAL=$i \ ./python -c pass done At least some of these fixes should probably be backported to 2.5.
* Issue 2235: __hash__ is once again inherited by default, but inheritance can ↵Nick Coghlan2008-07-151-4/+2
| | | | be blocked explicitly so that collections.Hashable remains meaningful
* Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sureMark Dickinson2008-07-021-10/+10
| | | | | | | | that the behaviour of Decimal doesn't change if/when re.UNICODE becomes assumed in Python 3.0. Also add a check that alternative Unicode digits (e.g. u'\N{FULLWIDTH DIGIT ONE}') are *not* accepted in a numeric string.
* Make sure that Context traps and flags dictionaries have values 0 and 1Mark Dickinson2008-05-041-2/+2
| | | | (as documented) rather than True and False.
* Some very minor changes to decimal.py in Python 2.6, aimedMark Dickinson2008-05-041-9/+9
| | | | | | | | | | at reducing the size of the diff between the 2.x decimal.py and 3.x decimal.py and thereby making future merges easier: - replace one instnace of an old-style raise statement - define __div__ in terms of __truediv__ instead of the other way around - make wording match on an exception message
* Backport Raymond's changes in r60508 to Python 2.6.Mark Dickinson2008-05-031-4/+4
| | | | 'Context flags get set, not incremented'
* Fixed some test structures. Thanks Mark Dickinson.Facundo Batista2008-05-021-5/+1
|
* Issue #2482: Make sure that the coefficient of a DecimalMark Dickinson2008-03-251-3/+3
| | | | | instance is always stored as a str instance, even when that Decimal has been created from a unicode string.
* Issue #2478: Decimal(sqrt(0)) failed when the decimal contextMark Dickinson2008-03-251-3/+3
| | | | was not explicitly supplied.
* Fix docstring typo.Mark Dickinson2008-02-291-1/+1
|
* Add __format__ method to Decimal, to support PEP 3101Mark Dickinson2008-02-291-0/+240
|
* Remove duplicate 'import re' in decimal.pyMark Dickinson2008-02-241-2/+1
|
* Fix decimal repr which should have used single quotes like other reprs.Raymond Hettinger2008-02-141-242/+242
|
* Bring decimal a bit closer to the spec for Reals.Raymond Hettinger2008-02-121-0/+14
|
* Typos in decimal comment and documentationMark Dickinson2008-02-101-1/+1
|
* Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaNMark Dickinson2008-02-061-39/+110
| | | | raise InvalidOperation (and return False if InvalidOperation is trapped).
* Add support for trunc().Raymond Hettinger2008-01-241-0/+2
|