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