mae.tut.num
Class Decimal

java.lang.Object
  extended bymae.tut.num.Number
      extended bymae.tut.num.Ordinal
          extended bymae.tut.num.Decimal
All Implemented Interfaces:
java.lang.Comparable, java.io.Serializable

public class Decimal
extends Ordinal

Represents a decimal number, implemented as a float.

See Also:
Serialized Form

Constructor Summary
Decimal(float x)
          Use factory method Factory.newDecimal(float), rather than this constructor
 
Method Summary
 Number add(Number n)
          Adds this Number to another Number n and returns the result.
 Number inverse()
          Returns the multiplicative inverse of this Number.
 Number mult(Number n)
          Multiplies this Number by another Number n and returns the result.
 java.lang.String toString()
          String representation of this Number
 float value()
          Returns the float value of this Number.
 
Methods inherited from class mae.tut.num.Ordinal
compareTo, equals
 
Methods inherited from class mae.tut.num.Number
hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Decimal

public Decimal(float x)
Use factory method Factory.newDecimal(float), rather than this constructor

Method Detail

add

public Number add(Number n)
Description copied from class: Number
Adds this Number to another Number n and returns the result.

If this Number and n are of the same type, returned result must be of that type.
If this and n are of different types, returned result must be as narrow as possible.
But in all cases add(n) and n.add(this) must return the same Number.

Specified by:
add in class Number

mult

public Number mult(Number n)
Description copied from class: Number
Multiplies this Number by another Number n and returns the result.

If this Number and n are of the same type, returned result must be of that type.
If this and n are of different types, returned result must be as narrow as possible.
But in all cases mult(n) and n.mult(this) must return the same Number.

Specified by:
mult in class Number

inverse

public Number inverse()
Description copied from class: Number
Returns the multiplicative inverse of this Number.

For any Number n, if inverse() is defined, n.inverse().inverse() must be equal to n.
Also n.inverse().mult(n).value() must be 1.0

Specified by:
inverse in class Number

value

public float value()
Description copied from class: Number
Returns the float value of this Number.

Specified by:
value in class Number

toString

public java.lang.String toString()
String representation of this Number