mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix mul
This commit is contained in:
parent
20779bdd33
commit
34e4efcc3c
@ -12,8 +12,10 @@
|
|||||||
* 【core 】 增加Alias注解
|
* 【core 】 增加Alias注解
|
||||||
* 【core 】 修正NumberChineseFormatter和NumberWordFormatter(类名拼写错误)
|
* 【core 】 修正NumberChineseFormatter和NumberWordFormatter(类名拼写错误)
|
||||||
* 【all 】 修正equals,避免可能存在的空指针问题(pr#692@Github)
|
* 【all 】 修正equals,避免可能存在的空指针问题(pr#692@Github)
|
||||||
|
* 【core 】 提供一个自带默认值的Map(pr#87@Gitee)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
|
* 【core 】 修复NumberUtil.mul中null的结果错误问题(issue#I17Y4J@Gitee)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -410,9 +410,7 @@ public class NumberUtil {
|
|||||||
BigDecimal result = new BigDecimal(null == value ? "0" : value.toString());
|
BigDecimal result = new BigDecimal(null == value ? "0" : value.toString());
|
||||||
for (int i = 1; i < values.length; i++) {
|
for (int i = 1; i < values.length; i++) {
|
||||||
value = values[i];
|
value = values[i];
|
||||||
if (null != value) {
|
result = result.multiply(new BigDecimal(null == value ? "0" : value.toString()));
|
||||||
result = result.multiply(new BigDecimal(value.toString()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package cn.hutool.core.util;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Console;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@ -246,4 +247,10 @@ public class NumberUtilTest {
|
|||||||
factorial = NumberUtil.factorial(5, 1);
|
factorial = NumberUtil.factorial(5, 1);
|
||||||
Assert.assertEquals(120, factorial);
|
Assert.assertEquals(120, factorial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void mulTest(){
|
||||||
|
final BigDecimal mul = NumberUtil.mul(new BigDecimal("10"), null);
|
||||||
|
Assert.assertEquals(BigDecimal.ZERO, mul);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user