📄 mathutil.java
字号:
package net.turbochen.graph.util;
import java.text.NumberFormat;
/**
* 提供数学统计工具.
* @author Turbo Chen
*/
public class MathUtil
{
public static double max(double[] d) throws InvalidDataException
{
if ( d == null ) throw new InvalidDataException();
double temp = d[0];
for ( int i = 0;i<d.length;i++ )
{
if (d[i] > temp ) temp = d[i];
}
return temp;
}
public static double min(double[] d) throws InvalidDataException
{
if ( d == null ) throw new InvalidDataException();
double temp = d[0];
for ( int i = 0;i<d.length;i++ )
{
if (d[i] < temp ) temp = d[i];
}
return temp;
}
public static int max(int[] d) throws InvalidDataException
{
if ( d == null ) throw new InvalidDataException();
if ( d == null ) throw new InvalidDataException();
int temp = d[0];
for ( int i = 0;i<d.length;i++ )
{
if (d[i] > temp ) temp = d[i];
}
return temp;
}
public static int min(int[] d) throws InvalidDataException
{
if ( d == null ) throw new InvalidDataException();
if ( d == null ) throw new InvalidDataException();
if ( d == null ) throw new InvalidDataException();
int temp = d[0];
for ( int i = 0;i<d.length;i++ )
{
if (d[i] < temp ) temp = d[i];
}
return temp;
}
public static String format(double value,String pattern)
{
java.text.DecimalFormat df = new java.text.DecimalFormat(pattern);
return df.format(value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -