Indeed, there is something wrong with the error handling of exponents

{{{
sage: a = 2 ** (2**63)
Traceback (most recent call last):
...
.../sage/rings/integer.pyx in sage.rings.integer.Integer._pow_
   2229                 r = smallInteger(1)
   2230         else:
-> 2231             raise OverflowError(f"exponent must be at most {LONG_MAX}")
   2232         if mpz_sgn(exp) >= 0:
   2233             return r

OverflowError: exponent must be at most 9223372036854775807
}}}
but
{{{
sage: a = 2 ** (2**62)
Traceback (most recent call last):
...
.../sage/rings/integer.pyx in sage.rings.integer.Integer.__pow__
   2149
   2150         if type(left) is type(right):
-> 2151             return (<Integer>left)._pow_(right)
   2152         elif isinstance(left, Element):
   2153             return coercion_model.bin_op(left, right, operator.pow)

.../sage/rings/integer.pyx in sage.rings.integer.Integer._pow_
   2213
   2214         if mpz_fits_slong_p(exp):
-> 2215             return self._pow_long(mpz_get_si(exp))
   2216
   2217         # Raising to an exponent which doesn't fit in a long overflows

.../sage/rings/integer.pyx in sage.rings.integer.Integer._pow_long
   2245         if n > 0:
   2246             x = PY_NEW(Integer)
-> 2247             sig_on()
   2248             mpz_pow_ui(x.value, self.value, n)
   2249             sig_off()

RuntimeError: Aborted
}}}

On Sun, 4 Sept 2022 at 11:58, Georgi Guninski <ggunin...@gmail.com> wrote:
>
> sage 9.0 on ubuntu 20.
>
> When raising symbolic expression to large integer power
> i get abort() with stack:
>
> gmp: overflow in mpz type
>
> /lib/x86_64-linux-gnu/libc.so.6(abort+0x12b)[0x7f26d1c7a859]
> /lib/x86_64-linux-gnu/libgmp.so.10(__gmpz_realloc+0xad)[0x7f26d048edcd]
> /lib/x86_64-linux-gnu/libgmp.so.10(__gmpz_n_pow_ui+0x7e7)[0x7f26d048ba97]
> /lib/x86_64-linux-gnu/libpynac.so.18(_ZNK5GiNaC7numeric5powerEl+0x114)[0x7f26683b1c14]
>
> The non-minimal testcase
> ===
> def binnk3u(n,k):  return ( (n/k)**(k))
> n1=(2*10**3);d0=29004853178239;n0=SR(log(n1));tt=binnk3u(n0+d0-1,(d0))
> print("passed :(")
> ===
>
> on sagecell i get no output, just an animated rotating circle.
>
> if possible please don't regress the following, which works:
>
> sage: log(pi)**(2**80)
> log(pi)^1208925819614629174706176
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/CAGUWgD_Un568rw_RfAUmS3YaGiwV4sGh49oVsUkGEC3gvbV1rA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAGEwAAkH6kzYXKibDmY23Y6ZhKCQ3UPt2Rwo6iHSvqvttz77qA%40mail.gmail.com.

Reply via email to