cbrtToInt method

int cbrtToInt()

Returns the cube root of this as an int, but only if this is a valid cube, otherwise throws an InvalidPowerException.

Implementation

int cbrtToInt() {
  final cbrt = this.cbrt();

  if (!cbrt.isValidInteger) {
    throw (InvalidPowerException(3, this));
  }

  return cbrt.toInt();
}