lz_power
The left number raised to the power of the right.
long lz_power( CLZNumber* leftOperand, CLZNumber* rightOperand, CLZNumber* targetNumber = nullptr );
A whole exponent is taken by repeated squaring, with no logarithm, so the cost follows the number of digits in the exponent rather than its size. Any other is ey ln x, worked wide enough for the answer's own size.
A negative number to a whole power is real: (−2)³ is −8. A negative number to a fraction has no real answer and is refused, kFailed, flagged not-a-number; lzc_power gives the complex one. Nought to the power nought is one.
Examples
| Call | Answer | Returns |
|---|---|---|
lz_power( 2, 0.5 ) | 1.414213562373095048801688724209698079 | kNoError |
lz_power( 2, 10 ) | 1024 | kNoError |
lz_power( −2, 3 ) | −8 | kNoError |
lz_power( −8, 0.5 ) | not a number | kFailed |
lz_power( 0, 0 ) | 1 | kNoError |
Each answer is what Addaptic printed for the call, at 36 places unless a setting is shown.
Returns
kNoError (0) when the answer is written. Otherwise an error code, with the answer flagged infinite or not-a-number; see Errors and flags.
See also
lz_raise_nThe left number raised to a whole power, the right.lz_exp_nThe left number raised to the power of the right.lz_root_nThe root of the left number whose order is the right.lzc_powerA complex number raised to a complex power, the principal value e^(w ln z).