pnuts.ext
Class Complex
java.lang.Object
|
+--java.lang.Number
|
+--pnuts.ext.Complex
- public class Complex
- extends java.lang.Number
- implements Numeric
An implementation of complex number.
This class is an examples of pnuts.lang.Numeric and
pnuts.lang.QuantityFactory.
A sample script to use this class is
here.
- See Also:
- Serialized Form
Constructor Summary |
Complex(java.lang.Number re,
java.lang.Number im)
|
Method Summary |
java.lang.Object |
add(java.lang.Object o)
adds the value of parameter to itself |
int |
compareTo(java.lang.Object o)
compare the object with the parameter. |
java.lang.Object |
divide(java.lang.Object o)
divides itself by the value of parameter |
double |
doubleValue()
|
float |
floatValue()
|
java.lang.Number |
getImaginary()
|
java.lang.Number |
getReal()
|
int |
intValue()
|
java.lang.Object |
inverse()
inverts itself |
long |
longValue()
|
java.lang.Object |
multiply(java.lang.Object o)
multiplies itself with the value of parameter |
java.lang.Object |
negate()
negates itself by the value of parameter |
java.lang.Object |
subtract(java.lang.Object o)
subtracts the value of parameter from the object |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Number |
byteValue,
shortValue |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Complex
public Complex(java.lang.Number re,
java.lang.Number im)
getReal
public java.lang.Number getReal()
getImaginary
public java.lang.Number getImaginary()
add
public java.lang.Object add(java.lang.Object o)
- Description copied from interface: Numeric
- adds the value of parameter to itself
- Specified by:
- add in interface Numeric
subtract
public java.lang.Object subtract(java.lang.Object o)
- Description copied from interface: Numeric
- subtracts the value of parameter from the object
- Specified by:
- subtract in interface Numeric
multiply
public java.lang.Object multiply(java.lang.Object o)
- Description copied from interface: Numeric
- multiplies itself with the value of parameter
- Specified by:
- multiply in interface Numeric
divide
public java.lang.Object divide(java.lang.Object o)
- Description copied from interface: Numeric
- divides itself by the value of parameter
- Specified by:
- divide in interface Numeric
negate
public java.lang.Object negate()
- Description copied from interface: Numeric
- negates itself by the value of parameter
- Specified by:
- negate in interface Numeric
inverse
public java.lang.Object inverse()
- Description copied from interface: Numeric
- inverts itself
- Specified by:
- inverse in interface Numeric
compareTo
public int compareTo(java.lang.Object o)
- Description copied from interface: Numeric
- compare the object with the parameter.
returns one of the followings:
NOT_EQUAL, LEFT_IS_BIGGER, RIGHT_IS_BIGGER, EQUAL
- Specified by:
- compareTo in interface Numeric
intValue
public int intValue()
- Overrides:
- intValue in class java.lang.Number
longValue
public long longValue()
- Overrides:
- longValue in class java.lang.Number
floatValue
public float floatValue()
- Overrides:
- floatValue in class java.lang.Number
doubleValue
public double doubleValue()
- Overrides:
- doubleValue in class java.lang.Number
toString
public java.lang.String toString()
- Overrides:
- toString in class java.lang.Object