Float
Date: 2020-06-16

org.jpl7

## 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 Singleton

  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:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. 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.

  See Also:
    `Term`, `Compound`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected double` | `value` This Float's immutable (double) value

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Float(double value)` Construct a Float with the supplied (double) value

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    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"

    - ### Methods inherited from class org.jpl7.Term

      `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`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### value

          protected final double value

      This Float's immutable (double) value

  - ### Constructor Detail

    - #### Float

          public Float(double value)

      Construct a Float with the supplied (double) value
      Parameters:
        `value` - this Float's value

  - ### 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

      Overrides:
        `args` in class `Term`
      Returns:
        the arguments of a Compound

    - #### doubleValue

          public final double doubleValue()

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

    - #### equals

          public boolean equals(java.lang.Object o)

      Two Floats are equal if they are the same object, or their values are equal
      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `o` - The Object to compare
      Returns:
        true if the Object satisfies the above condition

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `java.lang.Object`

    - #### 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

    - #### hasFunctor

          public final boolean hasFunctor(double val,
                                          int arity)

      Tests whether this Float's functor has (double) 'name' and 'arity'
      Overrides:
        `hasFunctor` in class `Term`
      Parameters:
        `val` - a possible name for the functor of a term
        `arity` - 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
      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

    - #### put

          protected final 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.
      Specified by:
        `put` in class `Term`
      Parameters:
        `varnames_to_vars` - A Map from variable names to Prolog variables.
        `term` - A (previously created) term_t which is to be set to a Prolog float corresponding to this Float's value

    - #### 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

    - #### 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
      Specified by:
        `type` in 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"
      Specified by:
        `typeName` in class `Term`
      Returns:
        the name of the type of this term, as one of "Compound", "Atom", "Variable", "Integer", "Float" or "JRef"