fix `nextpow`, `prevpow` for types without `typemax` (#49669)
Without this change `prevpow` and `nextpow` fail for, e.g., `BigInt`;
incorrectly throwing a `MethodError`. For example, calls like
`prevpow(3, big"10")` or `nextpow(3, big"10")` fail.
The issue is that the code incorrectly assumes the existence of a
`typemax` method.
Another issue was a missing promote for the arguments of a
`mul_with_overflow` call.
Fixes #57906
(cherry picked from commit 3627a85749e4aa8197edb56dd93d1b21fd54dbe8)