View Javadoc

1   package com.sharkysoft.math;
2   
3   import java.math.BigDecimal;
4   
5   /***
6    * Math-related functions.
7    *
8    * <p><b>Details:</b> <code>MathToolbox</code> is a miscellaneous collection of 
9    * generic math-<wbr>related functions.</p>
10   *
11   * @author Sharky
12   */
13  public class MathToolbox
14  {
15  
16  	////////////////////////////
17  	//                        //
18  	//  toScientificNotation  //
19  	//                        //
20  	////////////////////////////
21  
22  	/***
23  	 * Converts real value to scientific notation.
24  	 *
25  	 * <p><b>Details:</b> This method determines the scientific notation for the
26  	 * given real value.</p>
27  	 *
28  	 * @param ipVal the real value
29  	 * @return the scientific notation
30  	 */
31  	public static MantissaExponent toScientificNotation(final BigDecimal ipVal)
32  	{
33  		return new MantissaExponent(ipVal);
34  	}
35  
36  	/***
37  	 * Converts real value to scientific notation.
38  	 *
39  	 * <p><b>Details:</b> This method determines the scientific notation for the
40  	 * given real value.</p>
41  	 *
42  	 * @param idVal the real value
43  	 * @return the scientific notation
44  	 */
45  	public static MantissaExponent toScientificNotation(final double idVal)
46  	{
47  		return new MantissaExponent(idVal);
48  	}
49  
50  	/***
51  	 * Converts real value to scientific notation.
52  	 *
53  	 * <p><b>Details:</b> This method determines the scientific notation for the
54  	 * given real value.</p>
55  	 *
56  	 * @param ifVal the real value
57  	 * @return the scientific notation
58  	 */
59  	public static MantissaExponent toScientificNotation(final float ifVal)
60  	{
61  		return new MantissaExponent(ifVal);
62  	}
63  
64  	public static boolean isIrrational(final float ifValue)
65  	{
66  		return Float.isNaN(ifValue) || Float.isInfinite(ifValue);
67  	}
68  
69  	public static boolean isIrrational(final double idValue)
70  	{
71  		return Double.isNaN(idValue) || Double.isInfinite(idValue);
72  	}
73  
74  }
75