📄 mathfp.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd"><!--NewPage--><HTML><HEAD><!-- Generated by javadoc on Sat Feb 10 16:19:10 EST 2001 --><TITLE>: Class MathFP</TITLE><LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"></HEAD><BODY BGCOLOR="white"><!-- ========== START OF NAVBAR ========== --><A NAME="navbar_top"><!-- --></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0"><TR><TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"><A NAME="navbar_top_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="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-all.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></EM></TD></TR><TR><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> PREV CLASS NEXT CLASS</FONT></TD><TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> <A HREF="../../../../index.html" TARGET="_top"><B>FRAMES</B></A> <A HREF="MathFP.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><!-- ======== START OF CLASS DATA ======== --><H2><FONT SIZE="-1">net.jscience.math.kvm</FONT><BR>Class MathFP</H2><PRE>java.lang.Object | +--<B>net.jscience.math.kvm.MathFP</B></PRE><HR><DL><DT>public abstract class <B>MathFP</B><DT>extends java.lang.Object</DL><P>This class implements 32 bit fixed-point integer math functions. The intend of this class is to provide float like calculations for the KVM basic platform. However this class can be used where ever the int and String data type are supported. This class should be used on all platforms that do not support longs. <p> This implementation includes variable precision and allows the developer to change the precision during run-time anywhere between 12 and 3 bits for the fraction. Transparent scaling is added where possible to increase the range of the fixed-point integers. However caution should always be taken for numbers close to MAX_VALUE. <br><br> Example:<br><br> <code> int n = MathFP.toFP(12);<br> int m = MathFP.toFP("14.5");<br> int a = n + m;<br> a = a - MathFP.toFP("1.5");<br> a = MathFP.div(a,n);<br> a = MathFP.sqrt(a);<br> System.out.println(MathFP.toString(a));<br> </code> <br> <B>Author:</B> Onno Hommes<br> <B>Version:</B> 2.0.5<P><HR><P><!-- ======== INNER CLASS SUMMARY ======== --><!-- =========== FIELD SUMMARY =========== --><A NAME="field_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Field Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#E">E</A></B></CODE><BR> The fixed-point representation of the natural number (2.7183).</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#MAX_VALUE">MAX_VALUE</A></B></CODE><BR> The maximum fixed-point representation for the current precision.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#MIN_VALUE">MIN_VALUE</A></B></CODE><BR> The minimum fixed-point representation for the current precision.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#PI">PI</A></B></CODE><BR> The fixed-point representation of pi (3.1416)</TD></TR></TABLE> <!-- ======== CONSTRUCTOR SUMMARY ======== --><A NAME="constructor_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Constructor Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#MathFP()">MathFP</A></B>()</CODE><BR> </TD></TR></TABLE> <!-- ========== METHOD SUMMARY =========== --><A NAME="method_summary"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=2><FONT SIZE="+2"><B>Method Summary</B></FONT></TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#abs(int)">abs</A></B>(int n)</CODE><BR> Returns the absolute value of the fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#acos(int)">acos</A></B>(int r)</CODE><BR> Returns the arc cosine of the fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#add(int, int)">add</A></B>(int n, int m)</CODE><BR> Adds two fixed-point integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#asin(int)">asin</A></B>(int x)</CODE><BR> Returns the arc sine of the fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#atan(int)">atan</A></B>(int r)</CODE><BR> Returns the arc tangent of the radian fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#atan2(int, int)">atan2</A></B>(int y, int x)</CODE><BR> Returns the pricipal value of the arc tangent of y/x </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#convert(int, int)">convert</A></B>(int l, int o)</CODE><BR> Changes precision of a fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#cos(int)">cos</A></B>(int r)</CODE><BR> Returns the cosine of the radian fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#cot(int)">cot</A></B>(int r)</CODE><BR> Returns the cotangent of the radian fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#div(int, int)">div</A></B>(int n, int m)</CODE><BR> Divides two fixed-point integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#exp(int)">exp</A></B>(int x)</CODE><BR> The natural number raised to the power of a fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#getPrecision()">getPrecision</A></B>()</CODE><BR> Get the current runtime precision for MathFP.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#log(int)">log</A></B>(int s)</CODE><BR> Returns the natural logarithm of a fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#max(int, int)">max</A></B>(int n, int m)</CODE><BR> Returns the biggest number of the two fixed-point integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#min(int, int)">min</A></B>(int n, int m)</CODE><BR> Returns the smallest number of the two fixed-point integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#mul(int, int)">mul</A></B>(int n, int m)</CODE><BR> Multiplies two fixed-point integers.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#pow(int, int)">pow</A></B>(int b, int e)</CODE><BR> Returns a fixed-point integer raised to a fixed-point integer </TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD><TD><CODE><B><A HREF="../../../../net/jscience/math/kvm/MathFP.html#round(int, int)">round</A></B>(int x, int d)</CODE><BR> rounds a fixed-point integer.</TD></TR><TR BGCOLOR="white" CLASS="TableRowColor"><TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"><CODE>static int</CODE></FONT></TD>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -