Class Power

All Implemented Interfaces:
Serializable, Comparable, RoundingModes

public class Power extends AbstractCompositeNumber
A power, consisting of a base and an exponent.
Version:
$Revision: 1.3 $ $Date: 2002/08/16 20:51:08 $
Author:
Ernst de Haan (znerd@FreeBSD.org)
See Also:
  • Constructor Details

  • Method Details

    • createInstance

      public static Power createInstance(RealNumber base, RealNumber exponent) throws IllegalArgumentException
      Returns a Power with the specified operands.
      Parameters:
      base - the base for the power, not null.
      exponent - the exponent for the power, not null.
      Returns:
      the Power instance, possibly newly constructed.
      Throws:
      IllegalArgumentException - if base == null || exponent == null.
    • determineSign

      protected static int determineSign(RealNumber base, RealNumber exponent) throws IllegalArgumentException
      Computes the sign of a power with the specified operands.
      Parameters:
      base - the base for the power, not null.
      exponent - the exponent for the power, not null.
      Returns:
      the Power instance, possibly newly constructed.
      Throws:
      IllegalArgumentException - if base == null || exponent == null.
    • getBase

      public RealNumber getBase()
      Returns the base of this power.
      Returns:
      the base, never null.
    • getExponent

      public RealNumber getExponent()
      Returns the exponent of this power.
      Returns:
      the exponent, never null.
    • toBigDecimal

      public BigDecimal toBigDecimal(int precision, int roundingMode) throws IllegalArgumentException
      Description copied from class: RealNumber
      Converts the value of this number to a BigDecimal with the specified precision and rounding mode.
      Specified by:
      toBigDecimal in class RealNumber
      Parameters:
      precision - the number of digits behind the decimal point, >= 0.
      roundingMode - the rounding mode to use, one of the modes defined in class BigDecimal.
      Returns:
      a BigDecimal with the rounded value of this, never null.
      Throws:
      IllegalArgumentException - if one of the following applies:
      1. precision < 0
      2. roundingMode is not one of the valid rounding modes defined in class BigDecimal
    • trunc

      public IntegerNumber trunc()
      Description copied from class: RealNumber
      Rounds to an integer number towards 0.
      Overrides:
      trunc in class RealNumber
      Returns:
      this real number truncated to an integer, never null.