Opened 13 years ago
Closed 12 years ago
#5347 closed defect (fixed)
[with patch, positive review] divides() may fail for 1 on the rhs.
Reported by: | malb | Owned by: | somebody |
---|---|---|---|
Priority: | major | Milestone: | sage-4.1.2 |
Component: | basic arithmetic | Keywords: | ring element divides |
Cc: | mhansen | Merged in: | Sage 4.1.2.alpha2 |
Authors: | John Cremona | Reviewers: | Mike Hansen |
Report Upstream: | Work issues: | ||
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
sage: K = GF(7) sage: K(3).divides(1) False sage: K(3).divides(K(1)) Traceback (most recent call last) ... ZeroDivisionError: reduction modulo right not defined.
This is because of this code added at http://hg.sagemath.org/sage-main/rev/0cb746e1a4bd
def divides(self, x): return (x % self) == 0
Attachments (1)
Change History (4)
Changed 12 years ago by
comment:1 Changed 12 years ago by
- Keywords ring element divides added
- Summary changed from divides() may fail for 1 on the rhs. to [with patch, needs review] divides() may fail for 1 on the rhs.
The patch handles this by testing all the easy cases of a.divides(b) (a is 1 or a unit, b is zero) before trying the % operation. Doctest added to show that it works.
comment:2 Changed 12 years ago by
- Reviewers set to Mike Hansen
- Summary changed from [with patch, needs review] divides() may fail for 1 on the rhs. to [with patch, positive review] divides() may fail for 1 on the rhs.
Looks good to me.
comment:3 Changed 12 years ago by
- Merged in set to Sage 4.1.2.alpha2
- Resolution set to fixed
- Status changed from new to closed
Note: See
TracTickets for help on using
tickets.
Applies to 4.1.1