This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: decimal.py: two rotate() issues
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: mark.dickinson, skrah
Priority: normal Keywords:

Created on 2009-10-29 09:21 by skrah, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (6)
msg94649 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2009-10-29 09:21
Hi,

I got two issues with the all-important function rotate():

1. It should probably convert an integer argument:

>>> from decimal import *
>>> c = getcontext()
>>> c.prec = 4
>>> Decimal("1000000000").rotate(1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/decimal.py", line 3411, in rotate
    ans = self._check_nans(other, context)
  File "/usr/lib/python2.7/decimal.py", line 738, in _check_nans
    other_is_nan = other._isnan()


2. When the coefficient size is greater than prec, the most significant
digits should be truncated before rotating:

>>> c.prec = 4
>>> Decimal("1000000000").rotate(Decimal(1))
Decimal('1')


The result should be 0 (checked against decNumber).
msg94650 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-29 09:23
Agreed on both counts.  I'll take a look.
msg94656 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-29 10:46
The shift function should also accept an integer 2nd argument.
msg94658 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-29 12:04
There were a number of Decimal methods that failed to accept an integer 
second argument.  I've fixed that in r75944.
msg94659 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-29 12:11
And the shift and rotate bugs for large arguments are fixed in r75945.
msg94661 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2009-10-29 12:25
Merged (along with a test numbering fix in extra.decTest) in r75946 
(release26-maint), r75947 (py3k) and r75948 (release31-maint).

Thanks for the report!
History
Date User Action Args
2022-04-11 14:56:54adminsetgithub: 51482
2009-10-29 12:25:32mark.dickinsonsetstatus: open -> closed
priority: normal

components: + Library (Lib)
versions: + Python 3.1, Python 3.2
messages: + msg94661
type: behavior
resolution: fixed
stage: resolved
2009-10-29 12:11:48mark.dickinsonsetmessages: + msg94659
2009-10-29 12:04:10mark.dickinsonsetmessages: + msg94658
2009-10-29 10:46:02mark.dickinsonsetmessages: + msg94656
2009-10-29 09:23:57mark.dickinsonsetassignee: mark.dickinson
messages: + msg94650
2009-10-29 09:21:02skrahcreate