Class Product

All Implemented Interfaces:
Serializable, Comparable, RoundingModes

public class Product extends AbstractCompositeNumber
A product of two real numbers.
Version:
$Revision: 1.5 $ $Date: 2002/08/16 21:35:50 $
Author:
Ernst de Haan (znerd@FreeBSD.org)
See Also:
  • Constructor Details

  • Method Details

    • createInstance

      public static Product createInstance(RealNumber a, RealNumber b) throws IllegalArgumentException
      Returns a Product with the specified operands.
      Parameters:
      a - the first operand, not null.
      b - the second operand, not null.
      Returns:
      the Product instance, possibly newly constructed, never null.
      Throws:
      IllegalArgumentException - if a == null || b == null.
    • determineSign

      protected static int determineSign(RealNumber a, RealNumber b) throws IllegalArgumentException
      Computes the sign of a product with the specified operands.
      Parameters:
      a - the first operand, not null.
      b - the second operand, not null.
      Returns:
      the sign for the product of a and b.
      Throws:
      IllegalArgumentException - if a == null || b == null.
    • toBigDecimal

      public BigDecimal toBigDecimal(int precision, int roundingMode) throws IllegalArgumentException
      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 number, never null.
      Throws:
      IllegalArgumentException - if precision < 0 or if the rounding mode is not one of the valid rounding modes defined in BigDecimal.
    • trunc

      public IntegerNumber trunc()
      Rounds to an integer number towards 0.
      Overrides:
      trunc in class RealNumber
      Returns:
      this number truncated to an integer, not null.