shz_powif
SHZ_INLINE float shz_powif(float x, int n) SHZ_NOEXCEPT;Raises x to the integer power n, using exponentiation by squaring.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
x | float | |
n | int |
Returns
Section titled “Returns”float
Details
Section titled “Details”Unlike shz_powf(), this is not an approximation: the result is computed by repeated multiplication, taking popcount(|n|) + floor(log2(|n|)) multiplies, plus a single division by x when n is negative.
When n is a compile-time constant, this expands to GCC's optimal multiplication chain for that exponent instead.
shz_powif(x, 0) returns 1.0f for everyx, including 0.0f.- Rounding may differ slightly from multiplying
xby itselfntimes, or from powf().
Availability
Section titled “Availability”- C++ equivalent:
shz::powif - Type-generic form: none
- Back-ends: SH4: dedicated SH4 implementation · SW: portable C · SPU: shared C implementation
- Defined in:
sh4zam/shz_scalar.h:437 - Module: Scalar, section "Transcendental"