Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Class nl.coffee.math.Product

java.lang.Object
  |
  +--java.lang.Number
        |
        +--nl.coffee.math.AbstractRealNumber
              |
              +--nl.coffee.math.AbstractCompositeNumber
                    |
                    +--nl.coffee.math.Product

public class Product
extends AbstractCompositeNumber
A product of two real numbers.

Since:
JUMP_1.0
Version:
1.1 199809.24
Author:
Ernst de Haan
See Also:
Serialized Form

Field Summary
int sign
          The sign of this product.
 
Fields inherited from class nl.coffee.math.AbstractCompositeNumber
elements
 
Constructor Summary
Product(RealNumber a, RealNumber b)
          Constructs a Product based on the 2 specified operands.
 
Method Summary
static Product createInstance(RealNumber a, RealNumber b)
          Returns a Product with the specified operands.
static int determineSign(RealNumber a, RealNumber b)
          Computes the sign of a product with the specified operands.
int getSign()
          Determines the sign of this number.
int retryCompare(RealNumber n)
          Returns -1, 0 or 1 as this number is less than, equal to, or greater than n, where n is a real number.
java.math.BigDecimal toBigDecimal(int precision, int roundingMode)
          Converts the value of this number to a BigDecimal with the specified precision and rounding mode.
java.lang.String toString()
          Returns a textual representation of this object.
IntegerNumber trunc()
          Rounds to an integer number towards 0.
 
Methods inherited from class nl.coffee.math.AbstractCompositeNumber
getElement, getElementCount, getElements
 
Methods inherited from class nl.coffee.math.AbstractRealNumber
abs, add, byteValue, compareTo, divide, doubleValue, equals, fitsByte, fitsDouble, fitsFloat, fitsInt, fitsLong, fitsShort, floatValue, hashCode, intValue, invert, longValue, multiply, negate, pow, retryCompare, shortValue, subtract, toBigDecimal, toBigInteger
 
Methods inherited from class java.lang.Number
byteValue, doubleValue, floatValue, intValue, longValue, shortValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait
 

Field Detail

sign

protected int sign
The sign of this product. This field is set only once upon construction.
Constructor Detail

Product

protected Product(RealNumber a,
                  RealNumber b)
           throws java.lang.IllegalArgumentException
Constructs a Product based on the 2 specified operands.
Parameters:
operand1 - the first operand for the product.
operand2 - the second operand for the product.
Throws:
java.lang.IllegalArgumentException - if either argument is null.
Method Detail

createInstance

public static Product createInstance(RealNumber a,
                                     RealNumber b)
                                            throws java.lang.IllegalArgumentException
Returns a Product with the specified operands.
Parameters:
a - the first operand.
b - the second operand.
Returns:
the Product instance, possibly newly constructed.
Throws:
java.lang.IllegalArgumentException - if either argument is null.

determineSign

protected static int determineSign(RealNumber a,
                                   RealNumber b)
Computes the sign of a product with the specified operands.
Parameters:
operand1 - the first operand.
operand2 - the second operand.

getSign

public int getSign()
Determines the sign of this number. This method returns -1, 0, or 1 as this number is negative, zero, or positive.
Returns:
the sign of this number.

retryCompare

public int retryCompare(RealNumber n)
                throws java.lang.IllegalArgumentException,
                       CanNotCompareException
Returns -1, 0 or 1 as this number is less than, equal to, or greater than n, where n is a real number.
Parameters:
n - the number to compare to.
Returns:
-1 if this<n, 0 if this==n, 1 if this>n.
Throws:
java.lang.IllegalArgumentException - if the argument is null.
Overrides:
retryCompare in class AbstractRealNumber

toBigDecimal

public java.math.BigDecimal toBigDecimal(int precision,
                               int roundingMode)
                                 throws java.lang.IllegalArgumentException
Converts the value of this number to a BigDecimal with the specified precision and rounding mode.
Parameters:
precision - the number of digits behind the decimal point.
roundingMode - the rounding mode to use, one of the modes defined in class BigDecimal.
Returns:
a BigDecimal with the rounded value of this.
Throws:
java.lang.IllegalArgumentException - if precision<0 or the rounding mode is not one of the valid rounding modes defined in class BigDecimal.

trunc

public IntegerNumber trunc()
Rounds to an integer number towards 0.
Returns:
this number truncated to an integer.

toString

public java.lang.String toString()
Returns a textual representation of this object.
Returns:
a String representation of this object.
Overrides:
toString in class java.lang.Object

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD