public class Float extends Term
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) 1998 Fred Dushin
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
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.
Modifier and Type | Field and Description |
---|---|
protected double |
value
This Float's immutable (double) value
|
Constructor and Description |
---|
Float(double value)
Construct a Float with the supplied (double) value
|
Modifier and Type | Method and Description |
---|---|
Term[] |
args()
The arguments of this Term.
|
double |
doubleValue()
Returns the (double) value of this Float
|
boolean |
equals(java.lang.Object o)
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'
|
int |
hashCode() |
int |
intValue()
Returns the (double) value of this Float, converted to an int
|
long |
longValue()
Returns the (double) value of this Float, converted to a long
|
protected void |
put(java.util.Map<java.lang.String,term_t> varnames_to_vars,
term_t term)
To convert a JPL Float to a Prolog term, we put its value field into the
term_t as a float.
|
java.lang.String |
toString()
Returns a Prolog source text representation of this Float
|
int |
type()
returns the type of this term, as one of org.jpl7.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" or "JRef"
|
arg, arity, atomListToStringArray, atomType, bigValue, getSubst, getSubsts, getTerm, getTerm, hasFunctor, hasFunctor, hasFunctor, intArrayArrayToList, intArrayToList, isAtom, isAtomOfNameType, isBig, isBigInteger, isCompound, isFloat, isInteger, isJFalse, isJNull, isJRef, isJTrue, isJVoid, isList, isList, isListNil, isListPair, isVariable, jrefToObject, listLength, listLength, listToTermArray, listToTermArray, name, object, objectToJRef, put, putParams, putParams, putParams1, putParams2, putTerm, putTerms, ref, setName, stringArrayToList, termArrayToList, textParamsToTerm, textToTerm, toString, toTermArray
public Float(double value)
value
- this Float's valuepublic Term[] args()
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
public final double doubleValue()
doubleValue
in class Term
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- The Object to comparepublic int hashCode()
hashCode
in class java.lang.Object
public final float floatValue()
floatValue
in class Term
public final boolean hasFunctor(double val, int arity)
hasFunctor
in class Term
val
- a possible name for the functor of a termarity
- an arity 0+public final int intValue()
public final long longValue()
protected final void put(java.util.Map<java.lang.String,term_t> varnames_to_vars, term_t term)
public java.lang.String toString()
toString
in class java.lang.Object
public final int type()
Term
public java.lang.String typeName()
Term