Class Float
- java.lang.Object
-
- org.jpl7.Term
-
- org.jpl7.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 SingletonCopyright (C) 1998 Fred Dushin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-
Constructor Summary
Constructors Constructor Description Float(double value)
construct a Float with the supplied (double) value
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Term[]
args()
The arguments of this Term.double
doubleValue()
returns the (double) value of this Floatboolean
equals(java.lang.Object obj)
Two Floats are equal if they are the same object, or their values are equalfloat
floatValue()
returns the (double) value of this Float, converted to a floatboolean
hasFunctor(double val, int arity)
Tests whether this Float's functor has (double) 'name' and 'arity'int
intValue()
returns the (double) value of this Float, converted to an intjava.lang.Object
jrefToObject()
long
longValue()
returns the (double) value of this Float, converted to a longjava.lang.String
toString()
Returns a Prolog source text representation of this Floatint
type()
returns the type of this term, as one of org.jpl7.fli.Prolog.COMPOUND, .ATOM, .VARIABLE, .INTEGER, .FLOAT etcjava.lang.String
typeName()
returns the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"-
Methods inherited from class org.jpl7.Term
arg, arity, atomType, bigValue, hasFunctor, hasFunctor, hasFunctor, isAtom, isBig, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJRef, isJTrue, isJVoid, isListNil, isListPair, isVariable, listLength, name, object, objectToJRef, putParams, putTerm, ref, toString, toTermArray
-
-
-
-
Method Detail
-
args
public Term[] args()
Description copied from class:Term
The arguments of this Term.Note that a SWI Prolog 7.x compound term can have zero arguments.
This method returns an empty Term[] from an Atom, Float, Integer or JRef, approximating the behaviour of SWI Prolog's =../2
-
doubleValue
public final double doubleValue()
returns the (double) value of this Float- Overrides:
doubleValue
in classTerm
- Returns:
- the (double) value 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 classjava.lang.Object
- Parameters:
obj
- The Object to compare- Returns:
- true if the Object satisfies the above condition
-
floatValue
public final float floatValue()
returns the (double) value of this Float, converted to a float- Overrides:
floatValue
in classTerm
- Returns:
- the (double) value of this Float, converted to a float
-
hasFunctor
public final boolean hasFunctor(double val, int arity)
Tests whether this Float's functor has (double) 'name' and 'arity'- Overrides:
hasFunctor
in classTerm
- Parameters:
val
- a possible name for the functor of a termarity
- an arity 0+- Returns:
- whether this Float's functor has (double) 'name' and 'arity'
-
intValue
public final int intValue()
returns the (double) value of this Float, converted to an int
-
jrefToObject
public java.lang.Object jrefToObject()
- Overrides:
jrefToObject
in classTerm
- Returns:
- the Object which this JRef references
-
longValue
public final long longValue()
returns the (double) value of this Float, converted to a long
-
toString
public java.lang.String toString()
Returns a Prolog source text representation of this Float- Overrides:
toString
in classjava.lang.Object
- Returns:
- a Prolog source text representation of this Float
-
type
public final int type()
Description copied from class:Term
returns the type of this term, as one of org.jpl7.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" or "JRef"
-
-