Prolog Cafe v1.2

jp.ac.kobe_u.cs.prolog.lang
Class DoubleTerm

java.lang.Object
  extended by jp.ac.kobe_u.cs.prolog.lang.Term
      extended by jp.ac.kobe_u.cs.prolog.lang.NumberTerm
          extended by jp.ac.kobe_u.cs.prolog.lang.DoubleTerm
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Term>

public class DoubleTerm
extends NumberTerm

Floating point number. The class DoubleTerm wraps a value of primitive type double.

 Term t = new DoubleTerm(3.3333);
 double d = ((DoubleTerm)t).doubleValue();
 

See Also:
Serialized Form

Field Summary
protected  double val
          Holds a double value that this DoubleTerm represents.
 
Fields inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
AFTER, BEFORE, EQUAL
 
Constructor Summary
DoubleTerm(double i)
          Constructs a new Prolog floating point number that represents the specified double value.
 
Method Summary
 NumberTerm abs()
          Returns a NumberTerm whose value is abs(this).
 NumberTerm acos()
          Returns a NumberTerm whose value is acos(this).
 NumberTerm add(NumberTerm t)
          Returns a NumberTerm whose value is (this + t).
 NumberTerm and(NumberTerm t)
          Throws a type_error.
 int arithCompareTo(NumberTerm t)
          Compares two NumberTerm objects numerically.
 NumberTerm asin()
          Returns a NumberTerm whose value is asin(this).
 NumberTerm atan()
          Returns a NumberTerm whose value is tan(this).
 NumberTerm ceil()
          Returns a NumberTerm whose value is ceil(this).
 int compareTo(Term anotherTerm)
          Compares two terms in Prolog standard order of terms.
 boolean convertible(java.lang.Class type)
          Check whether this object is convertible with the given Java class type.
 NumberTerm cos()
          Returns a NumberTerm whose value is cos(this).
 NumberTerm divide(NumberTerm t)
          Returns a NumberTerm whose value is (this / t).
 double doubleValue()
          Returns the numeric value represented by this object after conversion to type double.
 boolean equals(java.lang.Object obj)
          Checks term equality of two terms.
 NumberTerm exp()
          Returns a NumberTerm whose value is exp(this).
 NumberTerm floatFractPart()
          Returns a NumberTerm whose value is the float-fractional-part of this.
 NumberTerm floatIntPart()
          Returns a NumberTerm whose value is the float-integer-part of this.
 NumberTerm floor()
          Returns a NumberTerm whose value is floor(this).
 int hashCode()
           
 NumberTerm intDivide(NumberTerm t)
          Throws a type_error.
 int intValue()
          Returns the numeric value represented by this object after conversion to type int.
 NumberTerm log()
          Returns a NumberTerm whose value is log(this).
 long longValue()
          Returns the numeric value represented by this object after conversion to type long.
 NumberTerm max(NumberTerm t)
          Returns a NumberTerm whose value is max(this, t).
 NumberTerm min(NumberTerm t)
          Returns a NumberTerm whose value is min(this, t).
 NumberTerm mod(NumberTerm t)
          Throws a type_error.
 NumberTerm multiply(NumberTerm t)
          Returns a NumberTerm whose value is (this * t).
 NumberTerm negate()
          Returns a NumberTerm whose value is (- this).
 NumberTerm not()
          Throws a type_error.
 NumberTerm or(NumberTerm t)
          Throws a type_error.
 NumberTerm pow(NumberTerm t)
          Returns a NumberTerm whose value is (thist).
 NumberTerm rint()
          Returns a NumberTerm whose value is rint(this).
 NumberTerm round()
          Returns a NumberTerm whose value is round(this).
 NumberTerm shiftLeft(NumberTerm t)
          Throws a type_error.
 NumberTerm shiftRight(NumberTerm t)
          Throws a type_error.
 NumberTerm signum()
          Returns a NumberTerm whose value is signum(this).
 NumberTerm sin()
          Returns a NumberTerm whose value is sin(this).
 NumberTerm sqrt()
          Returns a NumberTerm whose value is sqrt(this).
 NumberTerm subtract(NumberTerm t)
          Returns a NumberTerm whose value is (this - t).
 NumberTerm tan()
          Returns a NumberTerm whose value is tan(this).
 NumberTerm toDegrees()
          Returns a NumberTerm whose value is toDegrees(this).
 NumberTerm toFloat()
          Returns a NumberTerm whose value is (double)(this).
 java.lang.Object toJava()
          Returns a java.lang.Double corresponds to this DoubleTerm according to Prolog Cafe interoperability with Java.
 NumberTerm toRadians()
          Returns a NumberTerm whose value is toRadians(this).
 java.lang.String toString()
          Returns a string representation of this DoubleTerm.
 NumberTerm truncate()
          Returns a NumberTerm whose value is the truncate of this.
 boolean unify(Term t, Trail trail)
          Checks whether the argument term is unified with this one.
 double value()
          Returns the value of val.
 NumberTerm xor(NumberTerm t)
          Throws a type_error.
 
Methods inherited from class jp.ac.kobe_u.cs.prolog.lang.Term
convertible, copy, dereference, instanceOfTerm, isClosure, isDouble, isGround, isInteger, isJavaObject, isList, isNil, isNumber, isStructure, isSymbol, isVariable, toQuotedString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

val

protected double val
Holds a double value that this DoubleTerm represents.

Constructor Detail

DoubleTerm

public DoubleTerm(double i)
Constructs a new Prolog floating point number that represents the specified double value.

Method Detail

value

public double value()
Returns the value of val.

See Also:
val

unify

public boolean unify(Term t,
                     Trail trail)
Description copied from class: Term
Checks whether the argument term is unified with this one.

Specified by:
unify in class Term
Parameters:
t - the term to be unified with.
trail - Trail Stack.
Returns:
true if succeeds, otherwise false.

convertible

public boolean convertible(java.lang.Class type)
Description copied from class: Term
Check whether this object is convertible with the given Java class type.

Overrides:
convertible in class Term
Parameters:
type - the Java class type to compare with.
Returns:
the boolean whose value is convertible(Double.class, type).
See Also:
Term.convertible(Class, Class)

toJava

public java.lang.Object toJava()
Returns a java.lang.Double corresponds to this DoubleTerm according to Prolog Cafe interoperability with Java.

Overrides:
toJava in class Term
Returns:
a java.lang.Double object equivalent to this DoubleTerm.

toString

public java.lang.String toString()
Returns a string representation of this DoubleTerm.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Checks term equality of two terms. The result is true if and only if the argument is an instance of DoubleTerm and has the same double value as this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to compare with. This must be dereferenced.
Returns:
true if the given object represents a Prolog floating point number equivalent to this DoubleTerm, false otherwise.
See Also:
compareTo(jp.ac.kobe_u.cs.prolog.lang.Term)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(Term anotherTerm)
Compares two terms in Prolog standard order of terms.
It is noted that t1.compareTo(t2) == 0 has the same boolean value as t1.equals(t2).

Parameters:
anotherTerm - the term to compared with. It must be dereferenced.
Returns:
the value 0 if two terms are identical; a value less than 0 if this term is before the anotherTerm; and a value greater than 0 if this term is after the anotherTerm.

intValue

public int intValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type int.

Specified by:
intValue in class NumberTerm

longValue

public long longValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type long.

Specified by:
longValue in class NumberTerm

doubleValue

public double doubleValue()
Description copied from class: NumberTerm
Returns the numeric value represented by this object after conversion to type double.

Specified by:
doubleValue in class NumberTerm

arithCompareTo

public int arithCompareTo(NumberTerm t)
Description copied from class: NumberTerm
Compares two NumberTerm objects numerically.

Specified by:
arithCompareTo in class NumberTerm
Parameters:
t - the NumberTerm to compare with.
Returns:
the value 0 if this object is numerically equal to the argument NumberTerm; a value less than 0 if this object is numerically less than the argument NumberTerm; and a value greater than 0 if this object is numerically greater than the argument NumberTerm.

abs

public NumberTerm abs()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is abs(this).

Specified by:
abs in class NumberTerm

acos

public NumberTerm acos()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is acos(this).

Specified by:
acos in class NumberTerm

add

public NumberTerm add(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this + t).

Specified by:
add in class NumberTerm

and

public NumberTerm and(NumberTerm t)
Throws a type_error.

Specified by:
and in class NumberTerm
Throws:
IllegalTypeException

asin

public NumberTerm asin()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is asin(this).

Specified by:
asin in class NumberTerm

atan

public NumberTerm atan()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is tan(this).

Specified by:
atan in class NumberTerm

ceil

public NumberTerm ceil()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is ceil(this).

Specified by:
ceil in class NumberTerm

cos

public NumberTerm cos()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is cos(this).

Specified by:
cos in class NumberTerm

divide

public NumberTerm divide(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this / t).

Specified by:
divide in class NumberTerm
Throws:
EvaluationException - if the given argument NumberTerm represents 0.

exp

public NumberTerm exp()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is exp(this).

Specified by:
exp in class NumberTerm

floatIntPart

public NumberTerm floatIntPart()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the float-integer-part of this.

Specified by:
floatIntPart in class NumberTerm

floatFractPart

public NumberTerm floatFractPart()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the float-fractional-part of this.

Specified by:
floatFractPart in class NumberTerm

floor

public NumberTerm floor()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is floor(this).

Specified by:
floor in class NumberTerm

intDivide

public NumberTerm intDivide(NumberTerm t)
Throws a type_error.

Specified by:
intDivide in class NumberTerm
Throws:
IllegalTypeException

log

public NumberTerm log()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is log(this).

Specified by:
log in class NumberTerm
Throws:
EvaluationException - if this object represents 0.

max

public NumberTerm max(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is max(this, t).

Specified by:
max in class NumberTerm

min

public NumberTerm min(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is min(this, t).

Specified by:
min in class NumberTerm

mod

public NumberTerm mod(NumberTerm t)
Throws a type_error.

Specified by:
mod in class NumberTerm
Throws:
IllegalTypeException

multiply

public NumberTerm multiply(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this * t).

Specified by:
multiply in class NumberTerm

negate

public NumberTerm negate()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (- this).

Specified by:
negate in class NumberTerm

not

public NumberTerm not()
Throws a type_error.

Specified by:
not in class NumberTerm
Throws:
IllegalTypeException

or

public NumberTerm or(NumberTerm t)
Throws a type_error.

Specified by:
or in class NumberTerm
Throws:
IllegalTypeException

pow

public NumberTerm pow(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (thist).

Specified by:
pow in class NumberTerm

rint

public NumberTerm rint()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is rint(this).

Specified by:
rint in class NumberTerm

round

public NumberTerm round()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is round(this).

Specified by:
round in class NumberTerm

shiftLeft

public NumberTerm shiftLeft(NumberTerm t)
Throws a type_error.

Specified by:
shiftLeft in class NumberTerm
Throws:
IllegalTypeException

shiftRight

public NumberTerm shiftRight(NumberTerm t)
Throws a type_error.

Specified by:
shiftRight in class NumberTerm
Throws:
IllegalTypeException

signum

public NumberTerm signum()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is signum(this).

Specified by:
signum in class NumberTerm

sin

public NumberTerm sin()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is sin(this).

Specified by:
sin in class NumberTerm

sqrt

public NumberTerm sqrt()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is sqrt(this).

Specified by:
sqrt in class NumberTerm
Throws:
EvaluationException - if this object represents a floating point number less than 0.

subtract

public NumberTerm subtract(NumberTerm t)
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (this - t).

Specified by:
subtract in class NumberTerm

tan

public NumberTerm tan()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is tan(this).

Specified by:
tan in class NumberTerm

toDegrees

public NumberTerm toDegrees()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is toDegrees(this).

Specified by:
toDegrees in class NumberTerm

toFloat

public NumberTerm toFloat()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is (double)(this).

Specified by:
toFloat in class NumberTerm

toRadians

public NumberTerm toRadians()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is toRadians(this).

Specified by:
toRadians in class NumberTerm

truncate

public NumberTerm truncate()
Description copied from class: NumberTerm
Returns a NumberTerm whose value is the truncate of this.

Specified by:
truncate in class NumberTerm

xor

public NumberTerm xor(NumberTerm t)
Throws a type_error.

Specified by:
xor in class NumberTerm
Throws:
IllegalTypeException

Prolog Cafe v1.2

Copyright (C) 1997-2008 M.BANBARA and N.TAMURA