java中的數(shù)學(xué)計(jì)算函數(shù)
Math類:
java.lang.Math類中包含基本的數(shù)字操作,如指數(shù)、對(duì)數(shù)、平方根和三角函數(shù)。 java.math是一個(gè)包,提供用于執(zhí)行任意精度整數(shù)(BigInteger)算法和任意精度小數(shù)(BigDecimal)算法的類。 java.lang.Math類中包含E和PI兩個(gè)靜態(tài)常量,以及進(jìn)行科學(xué)計(jì)算的類(static)方法,可以直接通過類名調(diào)用。 public static final Double E = 2.7182818284590452354 public static final Double PI = 3.14159265358979323846 public static long abs(double x):傳回 x 的絕對(duì)值。X也可int long float public static long sin(double x): 傳回x徑度的正弦函數(shù)值 public static long cos(double x):傳回x徑度的余弦函數(shù)值 public static long tan(double x): 傳回x徑度的正切函數(shù)值 public static long asin(double x):傳回x值的反正弦函數(shù)值。 public static long acos(double x):傳回x值的反余弦函數(shù)值。 public static long atan(double x):傳回x值的反正切函數(shù)值。 public static long atan2(double x, double y):傳回極坐標(biāo)(polar)的θ值 public static long floor(double x):傳回不大于x的大整數(shù)值 public static long ceil(double x):傳回不小于x的最小整數(shù)值。 public static long exp(double x):傳回相當(dāng)于ex值 public static long log(double x):傳回x的自然對(duì)數(shù)函數(shù)值 public static long max(double x,double y):傳回x、y較大數(shù) public static long min(double x,double y):傳回x、y較小數(shù) public static long pow(double x,double y):傳回x的y次冪值 public static long sqrt(double x): 傳回x開平方值 public static long rint(double x):傳回最接近x的整數(shù)值 public static long round(double x):傳回x的四舍五入值 public static long toDegrees(double angrad):傳回將angrad徑度轉(zhuǎn)換成角度 public static long toRadians(double angdeg): 傳回將angdeg角度轉(zhuǎn)換成徑度 public static long random():傳回隨機(jī)數(shù)值,產(chǎn)生一個(gè)0-1之間的隨機(jī)數(shù)(不包括0和1)