jpl
Class Float

java.lang.Object
  extended by jpl.Term
      extended by jpl.Float

public class Float
extends Term

Float is a specialised Term with a double field, representing a Prolog 64-bit ISO/IEC floating point value. Once constructed, a Float's value cannot be altered.

 Float f = new Float( 3.14159265 );
 
A Float can be used (and re-used) in Compound Terms. Two Float instances are equal (by .equals()) iff their (double) values are equal.
Copyright (C) 2004 Paul Singleton

Copyright (C) 1998 Fred Dushin

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library Public License for more details.


See Also:
Term, Compound

Constructor Summary
Float(double value)
          This constructor creates a Float with the supplied (double) value.
 
Method Summary
 Term arg(int i)
          throws a JPLException (arg(int) is defined only for Compound and Atom)
 Term[] args()
          The (nonexistent) args of this Float
 int arity()
          Returns the arity (0) of this Float
 java.lang.String debugString()
          Deprecated.  
 double doubleValue()
          returns the (double) value of this Float
 boolean equals(java.lang.Object obj)
          Two Floats are equal if they are the same object, or their values are equal
 float floatValue()
          returns the (double) value of this Float, converted to a float
 boolean hasFunctor(double val, int arity)
          Tests whether this Float's functor has (double) 'name' and 'arity'
 boolean hasFunctor(int val, int arity)
          Tests whether this Float's functor has (int) 'name' and 'arity' (never)
 boolean hasFunctor(java.lang.String name, int arity)
          Tests whether this Float's functor has (String) 'name' and 'arity' (never)
 int intValue()
          returns the (double) value of this Float, converted to an int
 java.lang.Object jrefToObject()
           
 long longValue()
          returns the (double) value of this Float, converted to a long
 java.lang.String name()
          throws a JPLException (name() is defined only for Compound, Atom and Variable)
 java.lang.String toString()
          Returns a Prolog source text representation of this Float
 int type()
          returns the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc
 java.lang.String typeName()
          returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc
 double value()
          Deprecated.  
 
Methods inherited from class jpl.Term
debugString, isAtom, isCompound, isFloat, isInteger, isJFalse, isJNull, isJObject, isJRef, isJTrue, isJVoid, isVariable, listLength, objectToJRef, put, putParams, putParams, putTerm, toString, toTermArray
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Float

public Float(double value)
This constructor creates a Float with the supplied (double) value.

Parameters:
value - this Float's value
Method Detail

arg

public final Term arg(int i)
throws a JPLException (arg(int) is defined only for Compound and Atom)

Specified by:
arg in class Term
Returns:
the ith argument (counting from 1) of this Float (never)

args

public Term[] args()
The (nonexistent) args of this Float

Specified by:
args in class Term
Returns:
the (nonexistent) args of this Float

hasFunctor

public final boolean hasFunctor(java.lang.String name,
                                int arity)
Tests whether this Float's functor has (String) 'name' and 'arity' (never)

Specified by:
hasFunctor in class Term
Returns:
whether this Float's functor has (String) 'name' and 'arity' (never)

hasFunctor

public final boolean hasFunctor(int val,
                                int arity)
Tests whether this Float's functor has (int) 'name' and 'arity' (never)

Specified by:
hasFunctor in class Term
Returns:
whether this Float's functor has (int) 'name' and 'arity' (never)

hasFunctor

public final boolean hasFunctor(double val,
                                int arity)
Tests whether this Float's functor has (double) 'name' and 'arity'

Specified by:
hasFunctor in class Term
Returns:
whether this Float's functor has (double) 'name' and 'arity'

name

public final java.lang.String name()
throws a JPLException (name() is defined only for Compound, Atom and Variable)

Overrides:
name in class Term
Returns:
the name of this Float (never)

arity

public final int arity()
Returns the arity (0) of this Float

Overrides:
arity in class Term
Returns:
the arity (0) of this Float

intValue

public final int intValue()
returns the (double) value of this Float, converted to an int

Overrides:
intValue in class Term
Returns:
the (double) value of this Float, converted to an int

longValue

public final long longValue()
returns the (double) value of this Float, converted to a long

Overrides:
longValue in class Term
Returns:
the (double) value of this Float, converted to a long

floatValue

public final float floatValue()
returns the (double) value of this Float, converted to a float

Overrides:
floatValue in class Term
Returns:
the (double) value of this Float, converted to a float

doubleValue

public final double doubleValue()
returns the (double) value of this Float

Overrides:
doubleValue in class Term
Returns:
the (double) value of this Float

type

public final int type()
Description copied from class: Term
returns the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc

Specified by:
type in class Term
Returns:
the type of this term, as one of jpl.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etc

typeName

public java.lang.String typeName()
Description copied from class: Term
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc

Specified by:
typeName in class Term
Returns:
the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" etc

toString

public java.lang.String toString()
Returns a Prolog source text representation of this Float

Overrides:
toString in class java.lang.Object
Returns:
a Prolog source text representation of this Float

equals

public final boolean equals(java.lang.Object obj)
Two Floats are equal if they are the same object, or their values are equal

Overrides:
equals in class java.lang.Object
Parameters:
obj - The Object to compare
Returns:
true if the Object satisfies the above condition

jrefToObject

public java.lang.Object jrefToObject()
Specified by:
jrefToObject in class Term

value

public double value()
Deprecated. 

The immutable value of this jpl.Float object, as a Java double

Returns:
the Float's value

debugString

public java.lang.String debugString()
Deprecated. 

Returns a debug-friendly String representation of this Float

Specified by:
debugString in class Term
Returns:
a debug-friendly String representation of this Float