📄 mathfp.html
字号:
Overflows and underflows are not always flaged so be carefull when operating near boudry areas. Remember these numbers are fixed points so they are internally bigger then you might perceive.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to be multiplied.<DD><CODE>m</CODE> - the fixed-point integer multiplier<DT><B>Returns:</B><DD>an new fixed point integer representing n multiplied by m.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the function overflows.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="div(long, long)"><!-- --></A><H3>div</H3><PRE>public static long <B>div</B>(long n, long m)</PRE><DL><DD>Divides two fixed-point integers. <p> This method will divide the fixed point n by the fixed point m. Overflows and underflows are not flaged so be carefull when operating near boundry areas. This method includes floating point behavior also referred to as scaling. This scaling is transparent to the developer and increases the range of the division method at the cost off precision.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the dividend fixed-point integer.<DD><CODE>m</CODE> - the divider fixed-point integer.<DT><B>Returns:</B><DD>an new fixed point integer representing n divided by m.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="add(long, long)"><!-- --></A><H3>add</H3><PRE>public static long <B>add</B>(long n, long m)</PRE><DL><DD>Adds two fixed-point integers. <p> This method is provided for consistency only. Since the inputs are fixed-point integers you might as well use the + operator.<BR> MathFP.add(toFP(1),toFP(2)) equals toFP(1) + toFP(2).<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to add to.<DD><CODE>m</CODE> - the fixed-point integer to be added.<DT><B>Returns:</B><DD>an new fixed point integer representing the addition of n and m.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="sub(long, long)"><!-- --></A><H3>sub</H3><PRE>public static long <B>sub</B>(long n, long m)</PRE><DL><DD>Subtracts two fixed-point integers. <p> This method is provided for consistency only. Since the inputs are fixed-point integers you might as well use the - operator.<BR> MathFP.sub(toFP(2),toFP("1.5")) equals toFP(1) - toFP("1.5").<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to subtract from.<DD><CODE>m</CODE> - the fixed-point integer to be subtracted.<DT><B>Returns:</B><DD>an new fixed point integer representing the subtraction of n and m.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="abs(long)"><!-- --></A><H3>abs</H3><PRE>public static long <B>abs</B>(long n)</PRE><DL><DD>Returns the absolute value of the fixed-point integer. <p> If the fixed-point integer is smaller than 0 then it returns -n else it will return n.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to get the absolute value of.<DT><B>Returns:</B><DD>an new fixed point integer representing the absolute value of n.<DT><B>Since: </B><DD>KVM-DR4.1</DD></DL></DD></DL><HR><A NAME="sqrt(long, int)"><!-- --></A><H3>sqrt</H3><PRE>public static long <B>sqrt</B>(long n, int r)</PRE><DL><DD>Returns the square root of the the fixed-point integer. <p> This function calculates the square root of a fixed-point integer. This method is extreemly fast and is the shortest sqrt function available. This method allows the developer to specify the number of iterations (r) to use to extract the root from n to allow performance control. This is usefull if many sqrt calls have to be made. The higher the number the more precise the answer. Typical values for r range from 6 to 24 depending on the runtime precision. Higher numbers will not give you any better results. <p> This method uses the Newton method to extract the root.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to extract the root from.<DD><CODE>r</CODE> - an integer that specifies the number of iterations.<DT><B>Returns:</B><DD>the fixed-point integer sqrt of n.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - for negative inputs and overflows.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="sqrt(long)"><!-- --></A><H3>sqrt</H3><PRE>public static long <B>sqrt</B>(long n)</PRE><DL><DD>Returns the square root of the the fixed-point integer. <p> Internally this method uses the sqrt(n,r) with 24 iterations. Auto adjustment is not provided yet. All limitations of sqrt(n,r) apply.<DD><DL><DT><B>Parameters:</B><DD><CODE>n</CODE> - the fixed-point integer to extract the root from.<DT><B>Returns:</B><DD>the fixed-point integer sqrt of n.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - for negative input and overflows.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="sin(long)"><!-- --></A><H3>sin</H3><PRE>public static long <B>sin</B>(long r)</PRE><DL><DD>Returns the sine of the radian fixed-point integer. <p> Returns sine for a given radian. The input must be a fixed-point integer radian. The return value is ofcourse a fixed-point integer again. This sine function calculates the sine using a polynomial function.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - the radian fixed-point integer to get the sine value of.<DT><B>Returns:</B><DD>the sine for the radian n as a fixed-point integer.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="asin(long)"><!-- --></A><H3>asin</H3><PRE>public static long <B>asin</B>(long x)</PRE><DL><DD>Returns the arc sine of the fixed-point integer. <p> This method is the reverse of the sin function and uses a polynomial function to calculate the result. The function will only accept values between and equal to -1 and 1.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - a fixed-point integer to get the arc sine of.<DT><B>Returns:</B><DD>the arc sine of the fixed-point integer s.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the input is < -1 and > 1.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="cos(long)"><!-- --></A><H3>cos</H3><PRE>public static long <B>cos</B>(long r)</PRE><DL><DD>Returns the cosine of the radian fixed-point integer. <p> Returns cosine for a certain radian. The input must be a fixed-point integer radian. This function is based on sin.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - the radian fixed-point integer to get the cosine value of.<DT><B>Returns:</B><DD>the cosine for the radian r as a fixed-point integer.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="acos(long)"><!-- --></A><H3>acos</H3><PRE>public static long <B>acos</B>(long r)</PRE><DL><DD>Returns the arc cosine of the fixed-point integer. <p> This method is the reverse of the cos function. The function will only accept values between and equal to -1 and 1.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - a fixed-point integer to get the arc sine of.<DT><B>Returns:</B><DD>the arc sine of the fixed-point integer s.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the input is < -1 and > 1.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="tan(long)"><!-- --></A><H3>tan</H3><PRE>public static long <B>tan</B>(long r)</PRE><DL><DD>Returns the tangent of the radian fixed-point integer. <p> The input must be a fixed-point integer radian. Input values close to PI/2 or any multiplication of PI/2 will give unpredicted or smaller values than expected. PI/2 will result in an exception.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - the radian fixed-point integer to get the tangent value of.<DT><B>Returns:</B><DD>the tangent of the radian r as a fixed-point integer.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the input is PI/2 or any multplication of it.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="cot(long)"><!-- --></A><H3>cot</H3><PRE>public static long <B>cot</B>(long r)</PRE><DL><DD>Returns the cotangent of the radian fixed-point integer. <p> The input must be a fixed-point integer radian. This method has the same problems as tan. Since cot = 1/tan r<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - the radian fixed-point integer to get the tangent value of.<DT><B>Returns:</B><DD>the cotangent of the radian r as a fixed-point integer.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the input is 0, PI or any multplication of it.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="atan(long)"><!-- --></A><H3>atan</H3><PRE>public static long <B>atan</B>(long r)</PRE><DL><DD>Returns the arc tangent of the radian fixed-point integer. <p> The input must be a fixed-point integer radian.<DD><DL><DT><B>Parameters:</B><DD><CODE>r</CODE> - the radian fixed-point integer to get the tangent value of.<DT><B>Returns:</B><DD>the arc tangent of the radian r as a fixed-point integer.<DT><B>Throws:</B><DD><CODE>ArithmeticException.</CODE> - <DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="exp(long)"><!-- --></A><H3>exp</H3><PRE>public static long <B>exp</B>(long x)</PRE><DL><DD>The natural number raised to the power of a fixed-point integer. <p> Calculate the power of the natural number e raised to the value of a fixed-point integer. This function uses a fixed multiplication map for higher acuracy.<DD><DL><DT><B>Parameters:</B><DD><CODE>x</CODE> - the fixed-point integer exponent.<DT><B>Returns:</B><DD>the natural number e raised to the power of x.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the function overflows<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="log(long)"><!-- --></A><H3>log</H3><PRE>public static long <B>log</B>(long s)</PRE><DL><DD>Returns the natural logarithm of a fixed-point integer. <p> Calculates the natural logarithm of the given fixed-point integer. The fixed point integer must be greater than 0 otherwise an arithmetic exception will be thrown. This function uses a Taylor series and the famous ln(2) constant to calculate the logarithm.<DD><DL><DT><B>Parameters:</B><DD><CODE>s</CODE> - the fixed-point integer to get the logarithm of.<DT><B>Returns:</B><DD>the logarithm of s.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the input is <= 0.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="pow(long, long)"><!-- --></A><H3>pow</H3><PRE>public static long <B>pow</B>(long b, long e)</PRE><DL><DD>Returns a fixed-point integer raised to a fixed-point integer <p> Calculate the power of a fixed-point integer raised to the power of a fixed-point integer. This function is based on the exp and log function. So any precision issues that are embedded in those methods are going to contribute to precision issues in this method. If you are raising to the power of 0.5 then you should use sqrt for higher accuracy. So use this function for things like 3.2 to the power of -4, 2.0 to the power of 0.3, etc...<DD><DL><DT><B>Parameters:</B><DD><CODE>b</CODE> - the fixed-point integer base.<DD><CODE>e</CODE> - the fixed-point integer exponent.<DT><B>Returns:</B><DD>the natural number s raised to the power of e.<DT><B>Throws:</B><DD><CODE>ArithmeticException</CODE> - if the function overflows.<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></DL></DD></DL><HR><A NAME="atan2(long, long)"><!-- --></A><H3>atan2</H3><PRE>public static long <B>atan2</B>(long y, long x)</PRE><DL><DD>Returns the pricipal value of the arc tangent of y/x <p> Compute the principal value of the arc tangent of y/x, using the signs of both parameters to determine the quadrant of the return value or inother words computes elementwise the angle in radian between the positive part of the x-axis and the line with origin in (0,0) which contains the point (x, y).<DD><DL><DT><B>Parameters:</B><DD><CODE>y</CODE> - the fixed-point integer<DD><CODE>x</CODE> - the fixed-point integer<DT><B>Returns:</B><DD>the pricipal value of the arctangent y/x<DT><B>Since: </B><DD>KVM CLDC 1.0</DD></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="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></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -