Raise informative error for exponentiation to negative power (see #3024)

(cherry picked from commit 79c9dfc5864df04fce95f5c5b7a328795f3fda85)
make #8784 work on Mac
(cherry picked from commit d2252d08d9b410d45a6ef955f6839ef2bcbe6ddf)