Float

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`

- - ### Constructor Summary

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

  - ### Method Summary

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

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

      `getClass, hashCode, notify, notifyAll, wait, wait, wait`

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

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

    - #### jrefToObject

          public java.lang.Object jrefToObject()

      Overrides:
        `jrefToObject` in class `Term`
      Returns:
        the Object which this JRef references

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

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