Mark Dickinson
a7a52ab7ee
Issue #7099 : Decimal.is_normal should return True for all nonzero
...
finite non-subnormal values, even those with exponent > Emax.
2009-10-20 13:33:03 +00:00
Mark Dickinson
15ae41c2db
Issue #7048 : logb should round its result when that result doesn't fit
...
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.)
2009-10-07 19:22:05 +00:00
Mark Dickinson
5cfa8044ff
Issue #6857 : Fix Decimal formatting to be consistent with existing float
...
formatting: both are now right-aligned by default.
2009-09-08 20:20:19 +00:00
Mark Dickinson
968f1690d3
#Issue 6795: Fix infinite recursion in long(Decimal('nan')); change int(Decimal('nan')) to raise ValueError instead of either returning NaN or raising InvalidContext.
2009-09-07 18:04:58 +00:00
Mark Dickinson
491ea55f28
Issue #6850 : Fix bug in Decimal._parse_format_specifier for formats
...
with no type specifier.
2009-09-07 16:17:41 +00:00
Mark Dickinson
7a7739d75e
Issue #6794 : Fix handling of NaNs in Decimal.compare_total and
...
Decimal.compare_total_mag.
2009-08-28 13:25:02 +00:00
Mark Dickinson
4326ad8f72
Issue #6595 : Allow Decimal constructor to accept non-European decimal
...
digits, as recommended by the specification. (Backport of r74279 from
py3k.)
2009-08-02 10:59:36 +00:00
Raymond Hettinger
a016debad0
Update spec version number.
2009-04-27 21:12:27 +00:00
Mark Dickinson
b14514a153
Fix bug in _insert_thousands_sep: too much zero padding could be
...
added for 'n' formats with non-repeating thousands-separator.
2009-03-18 08:22:51 +00:00
Mark Dickinson
277859d591
Issue #2110 : Add support for thousands separator and 'n' format specifier
...
to Decimal __format__ method.
2009-03-17 23:03:46 +00:00
Mark Dickinson
b065e52bc2
Fix bug in Decimal __format__ method that swapped left and right
...
alignment.
2009-03-17 18:01:03 +00:00
Raymond Hettinger
daeceb2de8
Add a version tag to the decimal module.
2009-03-10 04:49:21 +00:00
Raymond Hettinger
2c8585b0af
Register decimals as numbers.Number
2009-02-03 03:37:03 +00:00
Mark Dickinson
e52c31450d
Remove uses of cmp from the decimal module.
2009-01-25 10:39:15 +00:00
Mark Dickinson
65808ff0c0
More Python 2.3 compatibility fixes for decimal.py.
2009-01-04 21:22:02 +00:00
Mark Dickinson
6a961637a8
Fix Decimal.from_float to use valid Python 2.3 syntax, as per
...
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.
2009-01-04 21:10:56 +00:00
Raymond Hettinger
b7e835b820
Reapply r68191.
2009-01-03 19:08:10 +00:00
Raymond Hettinger
f4d8597a59
Issue 4796: Add from_float methods to the decimal module.
2009-01-03 19:02:23 +00:00
Mark Dickinson
4aa04db573
Issue #4812 : further renaming of internal Decimal constants, for clarity.
2009-01-03 12:07:20 +00:00
Mark Dickinson
c5de0969ca
Issue #4812 : add missing underscore prefix to some internal-use-only
...
constants in the decimal module. (Dec_0 becomes _Dec_0, etc.)
2009-01-02 23:07:08 +00:00
Facundo Batista
e29d435e0c
Issue #4084 : Fix max, min, max_mag and min_mag Decimal methods to
...
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.
2008-12-11 04:19:46 +00:00
Neal Norwitz
18aa388ca0
Fix:
...
* 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.
2008-08-24 05:04:52 +00:00
Nick Coghlan
53663a695e
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
2008-07-15 14:27:37 +00:00
Mark Dickinson
70c3289085
Replace occurrences of '\d' with '[0-9]' in Decimal regex, to make sure
...
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.
2008-07-02 09:37:01 +00:00
Mark Dickinson
71f3b85497
Make sure that Context traps and flags dictionaries have values 0 and 1
...
(as documented) rather than True and False.
2008-05-04 02:25:46 +00:00
Mark Dickinson
8aca9d032e
Some very minor changes to decimal.py in Python 2.6, aimed
...
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
2008-05-04 02:05:06 +00:00
Mark Dickinson
1840c1abca
Backport Raymond's changes in r60508 to Python 2.6.
...
'Context flags get set, not incremented'
2008-05-03 18:23:14 +00:00
Facundo Batista
ee340e501d
Fixed some test structures. Thanks Mark Dickinson.
2008-05-02 17:39:00 +00:00
Mark Dickinson
8e85ffa4b2
Issue #2482 : Make sure that the coefficient of a Decimal
...
instance is always stored as a str instance, even
when that Decimal has been created from a unicode string.
2008-03-25 18:47:59 +00:00
Mark Dickinson
3b24ccbe7e
Issue #2478 : Decimal(sqrt(0)) failed when the decimal context
...
was not explicitly supplied.
2008-03-25 14:33:23 +00:00
Mark Dickinson
f4da77765f
Fix docstring typo.
2008-02-29 03:29:17 +00:00
Mark Dickinson
1ddf1d8482
Add __format__ method to Decimal, to support PEP 3101
2008-02-29 02:16:37 +00:00
Mark Dickinson
6a123cb782
Remove duplicate 'import re' in decimal.py
2008-02-24 18:12:36 +00:00
Raymond Hettinger
abe3237187
Fix decimal repr which should have used single quotes like other reprs.
2008-02-14 02:41:22 +00:00
Raymond Hettinger
116f72fa5c
Bring decimal a bit closer to the spec for Reals.
2008-02-12 01:18:03 +00:00
Mark Dickinson
3a94ee05f7
Typos in decimal comment and documentation
2008-02-10 15:19:58 +00:00
Mark Dickinson
2fc9263df5
Issue 1979: Make Decimal comparisons (other than !=, ==) involving NaN
...
raise InvalidOperation (and return False if InvalidOperation is trapped).
2008-02-06 22:10:50 +00:00
Raymond Hettinger
5a05364049
Add support for trunc().
2008-01-24 19:05:29 +00:00
Andrew M. Kuchling
c8acc882a9
Docstring typos
2008-01-16 00:32:03 +00:00
Mark Dickinson
59bc20bb27
Issue 1780: Allow leading and trailing whitespace in Decimal constructor,
...
when constructing from a string. Disallow trailing newlines in
Context.create_decimal.
2008-01-12 01:56:00 +00:00
Raymond Hettinger
097a190303
Have Decimal.as_tuple return a named tuple.
2008-01-11 02:24:13 +00:00
Facundo Batista
52b25795c0
Issue #1757 : The hash of a Decimal instance is no longer affected
...
by the current context. Thanks Mark Dickinson.
2008-01-08 12:25:20 +00:00
Facundo Batista
0f5e7bf304
Some minor cleanups. Thanks Mark Dickinson.
2007-12-19 12:53:01 +00:00
Facundo Batista
e64acfad3d
Removed the private _rounding_decision: it was not needed, and the code
...
is now simpler. Thanks Mark Dickinson.
2007-12-17 14:18:42 +00:00
Facundo Batista
58f6f2e0c9
fma speedup by avoiding to create a Context. Thanks Mark Dickinson.
2007-12-04 16:31:53 +00:00
Facundo Batista
2ec7415db5
Faster _fix function, and some reordering for a more elegant
...
coding. Thanks Mark Dickinson.
2007-12-03 17:55:00 +00:00
Facundo Batista
62edb71556
Speedup and cleaning of __str__. Thanks Mark Dickinson.
2007-12-03 16:29:52 +00:00
Facundo Batista
0d157a0154
Reordering of __new__ to minimize isinstance() calls to most
...
used types. Thanks Mark Dickinson.
2007-11-30 17:15:25 +00:00
Facundo Batista
72bc54faed
Major change in the internal structure of the Decimal
...
number: now it does not store the mantissa as a tuple
of numbers, but as a string.
This avoids a lot of conversions, and achieves a
speedup of 40%. The API remains intact.
Thanks Mark Dickinson.
2007-11-23 17:59:00 +00:00
Facundo Batista
9b5e23148b
The constructor from tuple was way too permissive: it allowed bad
...
coefficient numbers, floats in the sign, and other details that
generated directly the wrong number in the best case, or triggered
misfunctionality in the alorithms.
Test cases added for these issues. Thanks Mark Dickinson.
2007-10-19 19:25:57 +00:00