addaptic

Reference Powers and roots

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

CallAnswerReturns
lz_power( 2, 0.5 )1.414213562373095048801688724209698079kNoError
lz_power( 2, 10 )1024kNoError
lz_power( −2, 3 )−8kNoError
lz_power( −8, 0.5 )not a numberkFailed
lz_power( 0, 0 )1kNoError

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_n The left number raised to a whole power, the right.
  • lz_exp_n The left number raised to the power of the right.
  • lz_root_n The root of the left number whose order is the right.
  • lzc_power A complex number raised to a complex power, the principal value e^(w ln z).