mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
6e5da8664c
commit
9ad2848bbd
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.5.3 (2020-12-04)
|
||||
# 5.5.3 (2020-12-05)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 IdcardUtil增加行政区划83(issue#1277@Github)
|
||||
|
@ -1516,7 +1516,7 @@ public class NumberUtil {
|
||||
*/
|
||||
public static int processMultiple(int selectNum, int minNum) {
|
||||
int result;
|
||||
result = mathSubnode(selectNum, minNum) / mathNode(selectNum - minNum);
|
||||
result = mathSubNode(selectNum, minNum) / mathNode(selectNum - minNum);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -2493,64 +2493,12 @@ public class NumberUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查value是否在[min,max]范围内
|
||||
*
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
* @param value 被检查值
|
||||
* @return 检查结果,范围内将返回true,否则返回false
|
||||
* @since 5.5.4
|
||||
*/
|
||||
public static boolean isBetween(int min, int max, int value) {
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查value是否在[min,max]范围内
|
||||
*
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
* @param value 被检查值
|
||||
* @return 检查结果,范围内将返回true,否则返回false
|
||||
* @since 5.5.4
|
||||
*/
|
||||
public static boolean isBetween(long min, long max, long value) {
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查value是否在[min,max]范围内
|
||||
*
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
* @param value 被检查值
|
||||
* @return 检查结果,范围内将返回true,否则返回false
|
||||
* @since 5.5.4
|
||||
*/
|
||||
public static boolean isBetween(float min, float max, float value) {
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查value是否在[min,max]范围内
|
||||
*
|
||||
* @param min 最小值
|
||||
* @param max 最大值
|
||||
* @param value 被检查值
|
||||
* @return 检查结果,范围内将返回true,否则返回false
|
||||
* @since 5.5.4
|
||||
*/
|
||||
public static boolean isBetween(double min, double max, double value) {
|
||||
return value >= min && value <= max;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------- Private method start
|
||||
private static int mathSubnode(int selectNum, int minNum) {
|
||||
private static int mathSubNode(int selectNum, int minNum) {
|
||||
if (selectNum == minNum) {
|
||||
return 1;
|
||||
} else {
|
||||
return selectNum * mathSubnode(selectNum - 1, minNum);
|
||||
return selectNum * mathSubNode(selectNum - 1, minNum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,4 +187,12 @@ public class ValidatorTest {
|
||||
zipCode = Validator.isZipCode("102629");
|
||||
Assert.assertTrue(zipCode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBetweenTest() {
|
||||
Assert.assertTrue(Validator.isBetween(0, 0, 1));
|
||||
Assert.assertTrue(Validator.isBetween(1L, 0L, 1L));
|
||||
Assert.assertTrue(Validator.isBetween(0.19f, 0.1f, 0.2f));
|
||||
Assert.assertTrue(Validator.isBetween(0.19, 0.1, 0.2));
|
||||
}
|
||||
}
|
||||
|
@ -303,12 +303,4 @@ public class NumberUtilTest {
|
||||
Assert.assertEquals("0", NumberUtil.toStr(NumberUtil.sub(new BigDecimal("9600.0000000000"), new BigDecimal("9600.000000"))));
|
||||
Assert.assertEquals("0", NumberUtil.toStr(new BigDecimal("9600.00000").subtract(new BigDecimal("9600.000000000"))));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isBetweenTest() {
|
||||
Assert.assertTrue(NumberUtil.isBetween(0, 1, 0));
|
||||
Assert.assertTrue(NumberUtil.isBetween(0l, 1l, 1l));
|
||||
Assert.assertTrue(NumberUtil.isBetween(0.1f, 0.2f, 0.19f));
|
||||
Assert.assertTrue(NumberUtil.isBetween(0.1, 0.2, 0.19));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user