<ppdoc>
<copyright>
Copyright (c) 2001 by Addison Wesley Longman, Inc. This material may
be distributed only subject to the terms and conditions set forth in
the Open Publication License, v1.0 or later (the latest version is
presently available at http://www.opencontent.org/openpub/).
<p/>
Distribution of substantively modified versions of this document is
prohibited without the explicit permission of the copyright holder.
<p/>
Distribution of the work or derivative of the work in any standard
(paper) book form is prohibited unless prior permission is obtained
from the copyright holder.
</copyright>
<class name="Float" super="Numeric" type="class" ref="xref-000001">  
  <tt>Float</tt> objects represent real numbers using the native
  architecture's double-precision floating point representation.  
<p/>
  <methods type="instance">
        <method name="Arithmetic operations" ref="Arithmeticoperations">
      <callseq>
<p/>
      </callseq>
      <desc>
<p/>
      Performs various arithmetic operations on <obj>flt</obj>.                                    
<p/>
      <table>
<tr>
  <td><obj>flt</obj></td>
  <td>+</td>
  <td><obj>aNumeric</obj></td>
  <td>Addition</td>
</tr>
<tr>
  <td><obj>flt</obj></td>
  <td>--</td>
  <td><obj>aNumeric</obj></td>
  <td>Subtraction</td>
</tr>
<tr>
  <td><obj>flt</obj></td>
  <td>*</td>
  <td><obj>aNumeric</obj></td>
  <td>Multiplication</td>
</tr>
<tr>
  <td><obj>flt</obj></td>
  <td>/</td>
  <td><obj>aNumeric</obj></td>
  <td>Division</td>
</tr>
<tr>
  <td><obj>flt</obj></td>
  <td>%</td>
  <td><obj>aNumeric</obj></td>
  <td>Modulo</td>
</tr>
<tr>
  <td><obj>flt</obj></td>
  <td>**</td>
  <td><obj>aNumeric</obj></td>
  <td>Exponentiation</td>
</tr>
</table>
<p/>
      </desc>
    </method>
<p/>
        <method name="&lt;=&gt;" ref="_lt_eq_lt">
      <callseq>
        <obj>flt</obj> &lt;=&gt; <obj>aNumeric</obj>
        <returns>-1, 0, +1</returns>
      </callseq>
      <desc>
<p/>
      Returns -1, 0, or +1 depending on whether <obj>flt</obj> is less
      than, equal to, or greater than <obj>aNumeric</obj>. This is the
      basis for the tests in <tt>Comparable</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="ceil" ref="ceil">
      <callseq>
        <obj>flt</obj>.ceil <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the smallest <tt>Integer</tt> greater than or equal to <obj>flt</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        1.2.ceil
        2.0.ceil
        (-1.2).ceil
        (-2.0).ceil
]]></fullcode><rubycode>
<tr>
  <td><tt>1.2.ceil</tt></td>
  <td>&#187;</td>
  <td><tt>2</tt></td>
</tr>
<tr>
  <td><tt>2.0.ceil</tt></td>
  <td>&#187;</td>
  <td><tt>2</tt></td>
</tr>
<tr>
  <td><tt>(-1.2).ceil</tt></td>
  <td>&#187;</td>
  <td><tt>-1</tt></td>
</tr>
<tr>
  <td><tt>(-2.0).ceil</tt></td>
  <td>&#187;</td>
  <td><tt>-2</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="finite?" ref="finite_qm">
      <callseq>
        <obj>flt</obj>.finite? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>flt</obj> is a valid IEEE floating point
      number (it is not infinite, and <meth>nan?</meth> is <const>false</const>).
<p/>
      </desc>
    </method>
<p/>
        <method name="floor" ref="floor">
      <callseq>
        <obj>flt</obj>.floor <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns the largest integer less than or equal to <obj>flt</obj>.
<p/>
<codefragment>
<fullcode><![CDATA[        1.2.floor
        2.0.floor
        (-1.2).floor
        (-2.0).floor
]]></fullcode><rubycode>
<tr>
  <td><tt>1.2.floor</tt></td>
  <td>&#187;</td>
  <td><tt>1</tt></td>
</tr>
<tr>
  <td><tt>2.0.floor</tt></td>
  <td>&#187;</td>
  <td><tt>2</tt></td>
</tr>
<tr>
  <td><tt>(-1.2).floor</tt></td>
  <td>&#187;</td>
  <td><tt>-2</tt></td>
</tr>
<tr>
  <td><tt>(-2.0).floor</tt></td>
  <td>&#187;</td>
  <td><tt>-2</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="infinite?" ref="infinite_qm">
      <callseq>
        <obj>flt</obj>.infinite? <returns><tt>nil</tt>, -1,
          +1</returns>
      </callseq>
      <desc>
<p/>
      Returns <tt>nil</tt>, -1, or +1 depending on whether <obj>flt</obj> is finite,
      -infinity, or +infinity.
<p/>
<codefragment>
<fullcode><![CDATA[        (0.0).infinite?
        (-1.0/0.0).infinite?
        (+1.0/0.0).infinite?
]]></fullcode><rubycode>
<tr>
  <td><tt>(0.0).infinite?</tt></td>
  <td>&#187;</td>
  <td><tt>nil</tt></td>
</tr>
<tr>
  <td><tt>(-1.0/0.0).infinite?</tt></td>
  <td>&#187;</td>
  <td><tt>-1</tt></td>
</tr>
<tr>
  <td><tt>(+1.0/0.0).infinite?</tt></td>
  <td>&#187;</td>
  <td><tt>1</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="nan?" ref="nan_qm">
      <callseq>
        <obj>flt</obj>.nan? <returns><const>true</const> or <const>false</const></returns>
      </callseq>
      <desc>
<p/>
      Returns <const>true</const> if <obj>flt</obj> is an invalid IEEE
      floating point number.
<p/>
<codefragment>
<fullcode><![CDATA[        a = -1.0
        a.nan?
        a = Math.log(a)
        a.nan?
]]></fullcode><rubycode>
<tr>
  <td><tt>a<nbsp/>=<nbsp/>-1.0</tt></td>
  <td>&#187;</td>
  <td><tt>-1.0</tt></td>
</tr>
<tr>
  <td><tt>a.nan?</tt></td>
  <td>&#187;</td>
  <td><tt>false</tt></td>
</tr>
<tr>
  <td><tt>a<nbsp/>=<nbsp/>Math.log(a)</tt></td>
  <td>&#187;</td>
  <td><tt>NaN</tt></td>
</tr>
<tr>
  <td><tt>a.nan?</tt></td>
  <td>&#187;</td>
  <td><tt>true</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="round" ref="round">
      <callseq>
        <obj>flt</obj>.round <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Rounds <obj>flt</obj> to the nearest integer. Equivalent to:
<p/>
<codefragment>
<alltt><fullcode><![CDATA[        def round
          return floor(self+0.5) if self > 0.0
          return ceil(self-0.5)  if self < 0.0
          return 0.0
        end
]]></fullcode>
def<nbsp/>round
<nbsp/><nbsp/>return<nbsp/>floor(self+0.5)<nbsp/>if<nbsp/>self<nbsp/>&gt;<nbsp/>0.0
<nbsp/><nbsp/>return<nbsp/>ceil(self-0.5)<nbsp/><nbsp/>if<nbsp/>self<nbsp/>&lt;<nbsp/>0.0
<nbsp/><nbsp/>return<nbsp/>0.0
end
</alltt>
</codefragment>
<p/>
<codefragment>
<fullcode><![CDATA[        1.5.round
        (-1.5).round
]]></fullcode><rubycode>
<tr>
  <td><tt>1.5.round</tt></td>
  <td>&#187;</td>
  <td><tt>2</tt></td>
</tr>
<tr>
  <td><tt>(-1.5).round</tt></td>
  <td>&#187;</td>
  <td><tt>-2</tt></td>
</tr>
</rubycode>
<p/>
</codefragment>
<p/>
      </desc>
    </method>
<p/>
        <method name="to_f" ref="to_f">
      <callseq>
        <obj>flt</obj>.to_f <returns><obj>flt</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns <obj>flt</obj>.
<p/>
      </desc>
    </method>
<p/>
        <method name="to_i" ref="to_i">
      <callseq>
        <obj>flt</obj>.to_i <returns><obj>anInteger</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns <obj>flt</obj> truncated to an <tt>Integer</tt>.
<p/>
      </desc>
    </method>
<p/>
        <method name="to_s" ref="to_s">
      <callseq>
        <obj>flt</obj>.to_s <returns><obj>aString</obj></returns>
      </callseq>
      <desc>
<p/>
      Returns a string containing a representation of self. As well as
      a fixed or exponential form of the number, the call may return
      ``<tt>NaN</tt>'', ``<tt>Infinity</tt>'', and ``<tt>-Infinity</tt>''.
<p/>
      </desc>
    </method>
<p/>
  </methods>
<p/>
</class>
</ppdoc>
