smartOp.pow

Raise base to the exp power.

Errors that may be signalled if neither input is floating-point:

  • IntFlag.posOver or IntFlag.negOver if the absolute value of the result is too large to represent with the return type.
  • IntFlag.div0 if base == 0 and exp < 0.
  1. auto pow(const N base, const M exp)
    template smartOp(IntFlagPolicy policy)
    pow
    pure @safe nothrow @nogc
    (
    N
    M
    )
    (
    const N base
    ,
    const M exp
    )
    if (
    (
    isFloatingPoint!N &&
    isScalarType!M
    )
    ||
    (
    isScalarType!N &&
    isFloatingPoint!M
    )
    )
  2. auto pow(const N base, const M exp)

Examples

1 import checkedint.sticky : smartOp; // use IntFlagPolicy.sticky
2 
3 assert(smartOp.pow(-10, 3) == -1_000);
4 assert(smartOp.pow(16, 4uL) == 65536);
5 assert(smartOp.pow(2, -1) == 0);
6 
7 smartOp.pow(-3, 27);
8 assert(IntFlags.local.clear() == IntFlag.negOver);
9 smartOp.pow(0, -5);
10 assert(IntFlags.local.clear() == IntFlag.div0);

Meta