I am using the FP-package for multiple choice exams with AMC (automatic multiple choice). For randomization I make use of long formulas which sometimes lead to error messages. The reason for these error messages is that the FP-package seems to have problems with the power of negative numbers. It does not matter if e.g. (-5)^2 or pow(2, -5) is used, this always leads to the messages "FP error: Logarithm of negative value!" or "FP error: UPN stack is empty!". Of course the results are wrong.
Surprisingly, I have not found any posting about this wrong behavior. I cannot believe that I am the first to run into these problems. Any idea how to fix this? Attached please find a minimal document and the respective output.
\documentclass[10pt]{article}
\usepackage{fp}
\begin{document}
\setlength{\parindent}{0pt}
\FPeval\Result{5^2}
Result of 5\textasciicircum 2: \Result{} (correct)
\FPeval\Result{(-5)^2}
Result of (-5)\textasciicircum 2: \Result{} (wrong)
\FPeval\Result{abs(-5)^2}
Result of abs(-5)\textasciicircum 2: \Result{} (correct)
\FPeval\Result{pow(2,5)}
Result of pow(2, 5): \Result{} (correct)
\FPeval\Result{pow(2,-5)}
Result of pow(2, -5): \Result{} (wrong)
\FPeval\Result{pow(2,abs(-5))}
Result of pow(2, abs(-5)): \Result{} (correct)
\FPeval\Result{pow(-2,5)}
Result of pow(-2, 5): \Result{} (correct)
\FPeval\Result{pow(-2,-5)}
Result of pow(-2, -5): \Result{} (wrong)
\FPset\myvar{-5}
\FPeval\Result{pow(2,myvar)}
Result of \verb+\FPset\myvar{-5}+ and pow(2, myvar): \Result{} (wrong)
\end{document}
The tex-file results in the following output (FP 0.8 / texlive 2021 / Linux Mint 21.1):


\fpeval{5**2} \fpeval{(-5)**2} \fpeval{(-5)**(-2)} \fpeval{5**(-2)}. – Ulrike Fischer Jun 23 '23 at 11:56\FPeval\Result{pow(2,-1)}results inFP error: UPN stack is empty!. Quite strangely,\FPeval\Result{pow(2,(-1))}givesFP error: Logarithm of negative value!. Apparently, negative exponents are disallowed because of some internal implementation. – egreg Jun 23 '23 at 14:15