ai.krr
Class RealNumberSymbol

java.lang.Object
  extended by ai.krr.SyntaxAdaptableSymbol
      extended by ai.krr.NumericSymbol
          extended by ai.krr.RealNumberSymbol
All Implemented Interfaces:
Symbol, inf.compilers.SyntaxAdaptable, java.lang.Comparable<Symbol>

public class RealNumberSymbol
extends NumericSymbol

This class implements part of the foundations for symbolic programming in Java. A RealNumberSymbol consists solely of its double value.

The order between all NumericSymbols, i.e. IntegerSymbols and RealNumberSymbols, in defined as the order of their values. Thus, an IntegerSymbol can come before or after a RealNumberSymbol.

Author:
Gerhard Wickler

Constructor Summary
RealNumberSymbol(double val)
           This constructor creates a new RealNumberSymbol with the given value.
 
Method Summary
 int compareTo(NumericSymbol numSy)
           This function compares this RealNumberSymbol to the given NumericSymbol.
 double doubleValue()
           This function returns the value of this RealNumberSymbol as a Java double.
 int hashCode()
           This function returns the hash code of this Symbol.
 long intValue()
           This function returns the value of this RealNumberSymbol as a Java (approximate) long.
 java.lang.String toString()
           This function returns a printable representation of this RealNumberSymbol which is the value (a double) of this NumericSymbol.
 
Methods inherited from class ai.krr.NumericSymbol
compareTo, equals, getClassOrderIndex, isNumericSymbol
 
Methods inherited from class ai.krr.SyntaxAdaptableSymbol
isBooleanSymbol, isNamedSymbol, prettyPrint, read, write
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RealNumberSymbol

public RealNumberSymbol(double val)

This constructor creates a new RealNumberSymbol with the given value.

Parameters:
val - the numeric value of this symbol
Method Detail

intValue

public final long intValue()

This function returns the value of this RealNumberSymbol as a Java (approximate) long. This is done using ordinary casting.

Specified by:
intValue in class NumericSymbol
Returns:
the numeric value of this RealNumberSymbol

doubleValue

public final double doubleValue()

This function returns the value of this RealNumberSymbol as a Java double.

Specified by:
doubleValue in class NumericSymbol
Returns:
the numeric value of this RealNumberSymbol

compareTo

public int compareTo(NumericSymbol numSy)

This function compares this RealNumberSymbol to the given NumericSymbol. Two NumericSymbols are compared by value.

Specified by:
compareTo in class NumericSymbol
Parameters:
numSy - the NumericSymbol to which this RealNumberSymbol is compared
Returns:
0 if the two NumericSymbols are identical; -1 if the given Symbol should come after this NumericSymbol; and +1 if the given Symbol should come before this NumericSymbol

hashCode

public final int hashCode()

This function returns the hash code of this Symbol.

Overrides:
hashCode in class java.lang.Object
Returns:
a positive integer that may be used for hashing

toString

public java.lang.String toString()

This function returns a printable representation of this RealNumberSymbol which is the value (a double) of this NumericSymbol.

Overrides:
toString in class java.lang.Object
Returns:
a String representation for a double