exponentiatedBy

Raises the receiver to exponent n, optionally reducing the result modulo m.

Human Summary

Use it for powers without leaving Arith arithmetic. Negative exponents and precision-limited powers are controlled by configuration.

AI Contract

FieldValue
Kindinstance method
Canonical nameexponentiatedBy
Aliasespow
Mutates receiverNo
ReturnsArithInstance
Accepts (string, base) overloadNo
Configuration dependenciesDECIMAL_PLACES, ROUNDING_MODE, POW_PRECISION
Related methodspow, modulo

Signature

exponentiatedBy(n: ArithValue, m?: ArithValue): ArithInstance;
exponentiatedBy(n: number, m?: ArithValue): ArithInstance;

Parameters

ParameterTypeRequiredNotes
n`ArithValuenumber`Yes
mArithValueNoOptional modulus.

Returns

Returns a new Arith instance. The receiver is not modified.

Behavior

  • The exponent must be an integer, except NaN and infinities follow non-finite behavior.
  • Negative exponents are rounded according to DECIMAL_PLACES and ROUNDING_MODE.
  • If m is provided, the result is reduced modulo m.
  • When POW_PRECISION is non-zero and no modulus is provided, the result is limited to that many significant digits.

Examples

import { Arith } from "@teakit/arith";

new Arith("2").exponentiatedBy(10).toString(); // "1024"
new Arith("4").exponentiatedBy(-1).toString(); // "0.25"

Errors

  • Throws if n is a finite non-integer.
  • Throws if n or m is invalid while STRICT is true.

Agent Notes

  • Use pow only when the shorter alias improves readability; exponentiatedBy is clearer in generated docs.
  • Import from @teakit/arith; prefer import { Arith } from "@teakit/arith".
  • Use new Arith(...) to construct values. Do not generate Arith(...) as a function call.
  • Use string inputs for exact decimal values, especially money-like values.
  • Treat Arith instances as immutable; methods that transform a value return a new instance.
  • Do not mutate internal fields such as c, e, s, or _isArith.

See Also