# Revision history [back]

Well, if you want to change the representation of the objects, so when you type Integers(6)(5) it returns -1, I think that it is not implemented in sage.

However, if computing the symmetric representant of an element in Integers(n) can be done with the following code:

I use this function in some multimodular algorithms.

def lift_pm(p):
"""
Compute a representative of the element p mod n in [-n/2 , n/2]

INPUT:

- p an integer mod n

OUTPUT:

- An integer r such that  -n/2 < r <= n/2

EXAMPLES::

sage: p = Mod(2,4)
sage: lift_pm(p)
2
sage: p = Mod(3,4)
sage: lift_pm(p)
-1
"""
r = p.lift()
if r*2 > p.modulus():
r -= p.modulus()
return r