Skip to content

Commit

Permalink
Trac 16807: fix overflow in conversion Integer -> FiniteFieldElement_…
Browse files Browse the repository at this point in the history
…pari_ffelt
  • Loading branch information
pjbruin committed Aug 12, 2014
1 parent 00199fb commit 596fc84
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/sage/rings/finite_rings/element_pari_ffelt.pyx
Expand Up @@ -49,7 +49,19 @@ cdef GEN _INT_to_FFELT(GEN g, GEN x) except NULL:
Convert the t_INT `x` to an element of the field of definition of
the t_FFELT `g`.
This function must be called within pari_catch_sig_on() ... pari_catch_sig_off().
This function must be called within ``pari_catch_sig_on()``
... ``pari_catch_sig_off()``.
TESTS:
Converting large integers to finite field elements does not lead
to overflow errors (see :trac:`16807`)::
sage: p = previous_prime(2^64)
sage: F.<x> = GF(p^2)
sage: x * 2^63
9223372036854775808*x
"""
cdef GEN f, p = gel(g, 4), result
cdef long t
Expand All @@ -71,7 +83,7 @@ cdef GEN _INT_to_FFELT(GEN g, GEN x) except NULL:
elif t == t_FF_Flxq:
f = cgetg(3, t_VECSMALL)
set_gel(f, 1, gmael(g, 2, 1))
f[2] = itos(x)
f[2] = itou(x)
else:
pari_catch_sig_off()
raise TypeError("unknown PARI finite field type")
Expand Down

0 comments on commit 596fc84

Please sign in to comment.