Skip to content

Commit ada208e

Browse files
author
Noel Roemmele
committed
Fixed crash when exp(0) of p-adic numbers is called
1 parent dc99dc8 commit ada208e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sage/rings/padics/padic_generic_element.pyx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,14 @@ cdef class pAdicGenericElement(LocalGenericElement):
29592959
sage: x.exp(algorithm='generic') # indirect doctest # needs sage.libs.ntl
29602960
1 + w*7 + (4*w + 2)*7^2 + (w + 6)*7^3 + 5*7^4 + O(7^5)
29612961
2962+
TESTS::
2963+
2964+
Verify that :trac:`38037` is fixed::
2965+
2966+
sage: R.<a> = Zq(9)
2967+
sage: exp(R.zero())
2968+
1 + O(3^20)
2969+
29622970
AUTHORS:
29632971
29642972
- Genya Zaytman (2007-02-15)
@@ -2973,6 +2981,8 @@ cdef class pAdicGenericElement(LocalGenericElement):
29732981
R=self.parent()
29742982
p=self.parent().prime()
29752983
e=self.parent().absolute_e()
2984+
if self._is_exact_zero():
2985+
return R.one()
29762986
x_unit=self.unit_part()
29772987
p_unit=R(p).unit_part().lift_to_precision()
29782988
x_val=self.valuation()

0 commit comments

Comments
 (0)