public class Maths extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Maths.HashMaths |
| 构造器和说明 |
|---|
Maths() |
| 限定符和类型 | 方法和说明 |
|---|---|
static int |
abs(int value)
求绝对值
|
static int |
avg(int... values)
求平均值
|
static double |
avgDouble(double... values)
求平均值
|
static float |
avgFloat(float... values)
求平均值
|
static long |
avgLong(long... values)
求平均值
|
static Double |
formatPrecision(double value,
int precision)
格式化小数点后多少位
|
static Double |
formatPrecision(double value,
int precision,
RoundingMode roundingMode)
格式化小数点后多少位
|
static boolean |
isOutOfBounds(int index,
int length,
int capacity)
Determine if the requested
index and length will fit within capacity. |
static boolean |
isPower2(int value)
判断是否为 2的 power 值
|
static int |
max(int... array)
求最大值
|
static double |
maxDouble(double... array)
求最大值
|
static float |
maxFloat(float... array)
求最大值
|
static long |
maxLong(long... array)
求最大值
|
static int |
min(int... array)
求最小值
|
static double |
minDouble(double... array)
求最小值
|
static float |
minFloat(float... array)
求最小值
|
static long |
minLong(long... array)
求最小值
|
static int |
pow2Int(int pow) |
static int |
pow2Long(int pow) |
static long |
saturatedAdd(long a,
long b)
Returns the sum of
a and b unless it would overflow or underflow in which case
Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively. |
static long |
saturatedMultiply(long a,
long b)
Returns the product of
a and b unless it would overflow or underflow in which
case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively. |
static long |
saturatedPow(long b,
int k)
Returns the
b to the kth power, unless it would overflow or underflow in which
case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively. |
static long |
saturatedSubtract(long a,
long b)
Returns the difference of
a and b unless it would overflow or underflow in
which case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively. |
static int |
sum(int... values)
求总和
|
static double |
sumDouble(double... values)
求总和
|
static float |
sumFloat(float... values)
求总和
|
static long |
sumLong(long... values)
求总和
|
public static int max(int... array)
public static float maxFloat(float... array)
public static long maxLong(long... array)
public static double maxDouble(double... array)
public static int min(int... array)
public static float minFloat(float... array)
public static long minLong(long... array)
public static double minDouble(double... array)
public static boolean isOutOfBounds(int index,
int length,
int capacity)
index and length will fit within capacity.index - The starting index.length - The length which will be utilized (starting from index).capacity - The capacity that index + length is allowed to be within.true if the requested index and length will fit within capacity.
false if this would result in an index out of bounds exception.public static int abs(int value)
public static int avg(int... values)
public static float avgFloat(float... values)
public static long avgLong(long... values)
public static double avgDouble(double... values)
public static int sum(int... values)
public static float sumFloat(float... values)
public static long sumLong(long... values)
public static double sumDouble(double... values)
public static Double formatPrecision(double value, int precision)
value - 要格式化的值precision - 小数点后保留位数public static Double formatPrecision(double value, int precision, RoundingMode roundingMode)
value - 要格式化的值precision - 小数点后保留位数public static boolean isPower2(int value)
value - public static int pow2Int(int pow)
public static int pow2Long(int pow)
public static long saturatedAdd(long a,
long b)
a and b unless it would overflow or underflow in which case
Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively.public static long saturatedSubtract(long a,
long b)
a and b unless it would overflow or underflow in
which case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively.public static long saturatedMultiply(long a,
long b)
a and b unless it would overflow or underflow in which
case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively.public static long saturatedPow(long b,
int k)
b to the kth power, unless it would overflow or underflow in which
case Long.MAX_VALUE or Long.MIN_VALUE is returned, respectively.Copyright © 2022. All rights reserved.