|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Real
This interface provides a way to completely abstract mathematical
operations, allowing you to swap data types in a program with very little
work. There are currently only two implementations: ADouble and AFloat. In
the future, there will be others. For example, a BigDecimal based
implementation (if I can figure out how to handle forcing a precision level
under 1.4.2). There are also plans in place to have a fixed-point based
implementation.
This interfaces implementations are named the way they are because
Double, Float, etc. are already taken by the java.lang package. I chose to
add the A on the beginning, to represent that the implementing classes
include arithmetic operations.
API Stability: Alpha; I may add a fixedPointValue() method,
should I ever get around to implementing a fixed point library. The thing
stopping me from doing this is the exponential and trigonometry methods.
I'm just as likely to re-implement this as an abstract class and give
the typecasting operations concrete implementations.
Method Summary | |
---|---|
Real |
abs()
Returns the absolute value of this Real. |
Real |
acos()
Returns the arc cosine of this Real. |
Real |
add(Real v)
Adds this and another Real together, returning the results. |
Real |
asin()
Returns the arc sine of this Real. |
Real |
atan()
Returns the arc tanget of this Real. |
java.math.BigDecimal |
bigDecimalValue()
Type-casts to a BigDecimal. |
byte |
byteValue()
Type-casts to a byte. |
int |
compareTo(java.lang.Object o)
Compares this Real with o. |
int |
compareTo(Real v)
Compares this Real with v. |
Real |
cos()
Returns the cosine of this Real. |
Real |
divide(Real v)
Divides this by another Real together, returning the results. |
double |
doubleValue()
Type-casts to a double. |
Real |
exp()
Returns Euler's number raised by this Real. |
float |
floatValue()
Type-casts to a float. |
int |
intValue()
Type-casts to an int. |
Real |
log()
Returns the natural logarithm of this Real. |
long |
longValue()
Type-casts to a long. |
Real |
max(Real v)
Returns the maximum of this Real and another. |
Real |
min(Real v)
Returns the minimum of this Real and another. |
Real |
multiply(Real v)
Multiplies this and another Real together, returning the results. |
Real |
negate()
Returns the negation of this Real. |
Real |
pow(Real v)
Returns the power of this Real raised by another. |
short |
shortValue()
Type-casts to a short. |
Real |
signum()
Returns the signum of this Real. |
Real |
sin()
Returns the sine of this Real. |
Real |
sqrt()
Returns the square root of this Real. |
Real |
subtract(Real v)
Subtracts another Real from this, returning the results. |
Real |
tan()
Returns the tangent of this Real. |
java.lang.String |
toString()
Type-casts to a String. |
Method Detail |
---|
Real add(Real v)
Real subtract(Real v)
Real multiply(Real v)
Real divide(Real v)
Real abs()
Real negate()
Real signum()
Real min(Real v)
Real max(Real v)
Real pow(Real v)
Real sqrt()
Real log()
Real exp()
Real sin()
Real cos()
Real tan()
Real asin()
Real acos()
Real atan()
byte byteValue()
short shortValue()
int intValue()
long longValue()
float floatValue()
double doubleValue()
java.math.BigDecimal bigDecimalValue()
java.lang.String toString()
toString
in class java.lang.Object
int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
java.lang.ClassCastException
- if o isn't a Real.int compareTo(Real v)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |