#7016: Bizarre results when taking the mod of a p-adic number
----------------------+-----------------------------------------------------
 Reporter:  jonhanke  |       Owner:  tbd          
     Type:  defect    |      Status:  new          
 Priority:  critical  |   Milestone:  sage-4.1.2   
Component:  algebra   |    Keywords:  padic, mod, %
 Reviewer:            |      Author:  jonhanke     
   Merged:            |  
----------------------+-----------------------------------------------------

Comment(by roed):

 This is a consequence of the fact that those two elements have different
 parents:
 {{{
 sage: parent(1+O(2^20))
 2-adic Ring with capped relative precision 20
 sage: parent(Qp(2)(1))
 2-adic Field with capped relative precision 20
 }}}

 Most rings in sage return an element of the same ring when applying the
 operation %.  The function you want is residue.

 {{{
 sage: a = Zp(2)(1); b = Qp(2)(1)
 sage: a.residue(3), b.residue(3)
 (1, 1)
 sage: a.residue(3).parent(), b.residue(3).parent()
 (Ring of integers modulo 8, Ring of integers modulo 8)
 sage: c = Qp(2)(1/2)
 sage: c.residue(3)
 ---------------------------------------------------------------------------
 ValueError                                Traceback (most recent call
 last)

 ValueError: Element must have non-negative valuation in order to compute
 residue.
 }}}

 There are some tricky questions for % and // and how they relate.  A
 similar issue bit William this past spring, so maybe we should have a
 design discussion about how to solve it.  I'm probably not going to be
 working on the p-adics this fall though: my advisor wants me to work on my
 thesis.  ;-)

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7016#comment:3>
Sage <http://sagemath.org/>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to