📄 bigdecimal.html
字号:
<DL><DD>Compares this BigDecimal with the specified BigDecimal. Two BigDecimals that are equal in value but have a different scale (like 2.0 and 2.00) are considered equal by this method. This method is provided in preference to individual methods for each of the six boolean comparison operators (<, ==, >, >=, !=, <=). The suggested idiom for performing these comparisons is: <tt>(x.compareTo(y)</tt> <<i>op</i>> <tt>0)</tt>, where <<i>op</i>> is one of the six comparison operators.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>val</CODE> - BigDecimal to which this BigDecimal is to be compared.<DT><B>Returns:</B><DD>-1, 0 or 1 as this BigDecimal is numerically less than, equal to, or greater than <tt>val</tt>.</DL></DD></DL><HR><A NAME="compareTo(java.lang.Object)"><!-- --></A><H3>compareTo</H3><PRE>public int <B>compareTo</B>(<A HREF="../../java/lang/Object.html">Object</A> o)</PRE><DL><DD>Compares this BigDecimal with the specified Object. If the Object is a BigDecimal, this method behaves like <tt>compareTo(BigDecimal)</tt>. Otherwise, it throws a <tt>ClassCastException</tt> (as BigDecimals are comparable only to other BigDecimals).<DD><DL><DT><B>Specified by: </B><DD><CODE><A HREF="../../java/lang/Comparable.html#compareTo(java.lang.Object)">compareTo</A></CODE> in interface <CODE><A HREF="../../java/lang/Comparable.html">Comparable</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>o</CODE> - Object to which this BigDecimal is to be compared.<DT><B>Returns:</B><DD>a negative number, zero, or a positive number as this BigDecimal is numerically less than, equal to, or greater than <tt>o</tt>, which must be a BigDecimal.<DT><B>Throws:</B><DD><CODE><A HREF="../../java/lang/ClassCastException.html">ClassCastException</A></CODE> - <tt>o</tt> is not a BigDecimal.<DT><B>Since: </B><DD>1.2</DD><DT><B>See Also: </B><DD><A HREF="../../java/math/BigDecimal.html#compareTo(java.math.BigDecimal)"><CODE>compareTo(java.math.BigDecimal)</CODE></A>, <A HREF="../../java/lang/Comparable.html"><CODE>Comparable</CODE></A></DL></DD></DL><HR><A NAME="equals(java.lang.Object)"><!-- --></A><H3>equals</H3><PRE>public boolean <B>equals</B>(<A HREF="../../java/lang/Object.html">Object</A> x)</PRE><DL><DD>Compares this BigDecimal with the specified Object for equality. Unlike compareTo, this method considers two BigDecimals equal only if they are equal in value and scale (thus 2.0 is not equal to 2.00 when compared by this method).<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#equals(java.lang.Object)">equals</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - Object to which this BigDecimal is to be compared.<DT><B>Returns:</B><DD><tt>true</tt> if and only if the specified Object is a BigDecimal whose value and scale are equal to this BigDecimal's.<DT><B>See Also: </B><DD><A HREF="../../java/math/BigDecimal.html#compareTo(java.math.BigDecimal)"><CODE>compareTo(java.math.BigDecimal)</CODE></A></DL></DD></DL><HR><A NAME="min(java.math.BigDecimal)"><!-- --></A><H3>min</H3><PRE>public <A HREF="../../java/math/BigDecimal.html">BigDecimal</A> <B>min</B>(<A HREF="../../java/math/BigDecimal.html">BigDecimal</A> val)</PRE><DL><DD>Returns the minimum of this BigDecimal and <tt>val</tt>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>val</CODE> - value with with the minimum is to be computed.<DT><B>Returns:</B><DD>the BigDecimal whose value is the lesser of this BigDecimal and <tt>val</tt>. If they are equal, as defined by the <tt>compareTo</tt> method, either may be returned.<DT><B>See Also: </B><DD><A HREF="../../java/math/BigDecimal.html#compareTo(java.math.BigDecimal)"><CODE>compareTo(java.math.BigDecimal)</CODE></A></DL></DD></DL><HR><A NAME="max(java.math.BigDecimal)"><!-- --></A><H3>max</H3><PRE>public <A HREF="../../java/math/BigDecimal.html">BigDecimal</A> <B>max</B>(<A HREF="../../java/math/BigDecimal.html">BigDecimal</A> val)</PRE><DL><DD>Returns the maximum of this BigDecimal and <tt>val</tt>.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>val</CODE> - value with with the maximum is to be computed.<DT><B>Returns:</B><DD>the BigDecimal whose value is the greater of this BigDecimal and <tt>val</tt>. If they are equal, as defined by the <tt>compareTo</tt> method, either may be returned.<DT><B>See Also: </B><DD><A HREF="../../java/math/BigDecimal.html#compareTo(java.math.BigDecimal)"><CODE>compareTo(java.math.BigDecimal)</CODE></A></DL></DD></DL><HR><A NAME="hashCode()"><!-- --></A><H3>hashCode</H3><PRE>public int <B>hashCode</B>()</PRE><DL><DD>Returns the hash code for this BigDecimal. Note that two BigDecimals that are numerically equal but differ in scale (like 2.0 and 2.00) will generally <i>not</i> have the same hash code.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#hashCode()">hashCode</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>hash code for this BigDecimal.</DL></DD></DL><HR><A NAME="toString()"><!-- --></A><H3>toString</H3><PRE>public <A HREF="../../java/lang/String.html">String</A> <B>toString</B>()</PRE><DL><DD>Returns the string representation of this BigDecimal. The digit-to- character mapping provided by <tt>Character.forDigit</tt> is used. A leading minus sign is used to indicate sign, and the number of digits to the right of the decimal point is used to indicate scale. (This representation is compatible with the (String) constructor.)<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Object.html#toString()">toString</A></CODE> in class <CODE><A HREF="../../java/lang/Object.html">Object</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>String representation of this BigDecimal.<DT><B>See Also: </B><DD><A HREF="../../java/lang/Character.html#forDigit(int, int)"><CODE>Character.forDigit(int, int)</CODE></A>, <A HREF="../../java/math/BigDecimal.html#BigDecimal(java.lang.String)"><CODE>BigDecimal(java.lang.String)</CODE></A></DL></DD></DL><HR><A NAME="toBigInteger()"><!-- --></A><H3>toBigInteger</H3><PRE>public <A HREF="../../java/math/BigInteger.html">BigInteger</A> <B>toBigInteger</B>()</PRE><DL><DD>Converts this BigDecimal to a BigInteger. Standard <i>narrowing primitive conversion</i> as defined in <i>The Java Language Specification</i>: any fractional part of this BigDecimal will be discarded.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>this BigDecimal converted to a BigInteger.</DL></DD></DL><HR><A NAME="intValue()"><!-- --></A><H3>intValue</H3><PRE>public int <B>intValue</B>()</PRE><DL><DD>Converts this BigDecimal to an int. Standard <i>narrowing primitive conversion</i> as defined in <i>The Java Language Specification</i>: any fractional part of this BigDecimal will be discarded, and if the resulting "BigInteger" is too big to fit in an int, only the low-order 32 bits are returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#intValue()">intValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>this BigDecimal converted to an int.</DL></DD></DL><HR><A NAME="longValue()"><!-- --></A><H3>longValue</H3><PRE>public long <B>longValue</B>()</PRE><DL><DD>Converts this BigDecimal to a long. Standard <i>narrowing primitive conversion</i> as defined in <i>The Java Language Specification</i>: any fractional part of this BigDecimal will be discarded, and if the resulting "BigInteger" is too big to fit in a long, only the low-order 64 bits are returned.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#longValue()">longValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>this BigDecimal converted to an int.</DL></DD></DL><HR><A NAME="floatValue()"><!-- --></A><H3>floatValue</H3><PRE>public float <B>floatValue</B>()</PRE><DL><DD>Converts this BigDecimal to a float. Similar to the double-to-float <i>narrowing primitive conversion</i> defined in <i>The Java Language Specification</i>: if this BigDecimal has too great a magnitude to represent as a float, it will be converted to <tt>FLOAT.NEGATIVE_INFINITY</tt> or <tt>FLOAT.POSITIVE_INFINITY</tt> as appropriate.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#floatValue()">floatValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>this BigDecimal converted to a float.</DL></DD></DL><HR><A NAME="doubleValue()"><!-- --></A><H3>doubleValue</H3><PRE>public double <B>doubleValue</B>()</PRE><DL><DD>Converts this BigDecimal to a double. Similar to the double-to-float <i>narrowing primitive conversion</i> defined in <i>The Java Language Specification</i>: if this BigDecimal has too great a magnitude to represent as a double, it will be converted to <tt>DOUBLE.NEGATIVE_INFINITY</tt> or <tt>DOUBLE.POSITIVE_INFINITY</tt> as appropriate.<DD><DL><DT><B>Overrides:</B><DD><CODE><A HREF="../../java/lang/Number.html#doubleValue()">doubleValue</A></CODE> in class <CODE><A HREF="../../java/lang/Number.html">Number</A></CODE></DL></DD><DD><DL><DT><B>Returns:</B><DD>this BigDecimal converted to a double.</DL></DD></DL><!-- ========= END OF CLASS DATA ========= --><HR><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_bottom"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_bottom_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3"> <TR ALIGN="center" VALIGN="top"> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/BigDecimal.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> </TR></TABLE></TD><TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM><b>Java<sup><font size=-2>TM</font></sup> 2 Platform<br>Std. Ed. v1.3</b></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS <A HREF="../../java/math/BigInteger.html"><B>NEXT CLASS</B></A></FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="BigDecimal.html" TARGET="_top"><B>NO FRAMES</B></A></FONT></TD></TR><TR><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> SUMMARY: INNER | <A HREF="#field_summary">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD><TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">DETAIL: <A HREF="#field_detail">FIELD</A> | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD></TR></TABLE><!-- =========== END OF NAVBAR =========== --><HR><font size="-1"><a href="http://java.sun.com/cgi-bin/bugreport.cgi">Submit a bug or feature</a><br>For further API reference and developer documentation, see <a href="http://java.sun.com/products/jdk/1.3/devdocs-vs-specs.html">Java 2 SDK SE Developer Documentation</a>. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. <p>Java, Java 2D, and JDBC are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries.<br>Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road<br>Palo Alto, California, 94303, U.S.A. All Rights Reserved.</font></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -