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
a5b1e4a76a
commit
728957baa3
@ -56,7 +56,10 @@ public class Calculator {
|
|||||||
resultStack.push(tempResult.toString());
|
resultStack.push(tempResult.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Double.parseDouble(resultStack.pop());
|
|
||||||
|
// 当结果集中有多个数字时,可能是省略*,类似(1+2)3
|
||||||
|
return NumberUtil.mul(resultStack.toArray(new String[0])).doubleValue();
|
||||||
|
//return Double.parseDouble(resultStack.pop());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,4 +48,12 @@ public class CalculatorTest {
|
|||||||
final double conversion = Calculator.conversion("((-2395+0) * 0.3+140.24+35+90)/30");
|
final double conversion = Calculator.conversion("((-2395+0) * 0.3+140.24+35+90)/30");
|
||||||
Assert.assertEquals(-15.11D, conversion, 0.01);
|
Assert.assertEquals(-15.11D, conversion, 0.01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void issue2964Test() {
|
||||||
|
// 忽略数字之间的运算符,按照乘法对待。
|
||||||
|
// https://github.com/dromara/hutool/issues/2964
|
||||||
|
final double calcValue = Calculator.conversion("(11+2)12");
|
||||||
|
Assert.assertEquals(156D, calcValue, 0.001);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user