Package com.luna.common.text
Class Calculator
java.lang.Object
com.luna.common.text.Calculator
数学表达式计算工具类
见:https://github.com/looly/hutool/issues/1090#issuecomment-693750140
见:https://github.com/looly/hutool/issues/1090#issuecomment-693750140
- Since:
- 5.4.3
- Author:
- trainliang, looly
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
按照给定的表达式计算boolean
compare
(char cur, char peek) 利用ASCII码-40做下标去算术符号优先级static double
conversion
(String expression) 计算表达式的值static String
getPrintSize
(long size) 字节转kb/mb/gb
-
Constructor Details
-
Calculator
public Calculator()
-
-
Method Details
-
conversion
计算表达式的值- Parameters:
expression
- 表达式- Returns:
- 计算结果
-
getPrintSize
字节转kb/mb/gb- Parameters:
size
-- Returns:
-
calculate
按照给定的表达式计算- Parameters:
expression
- 要计算的表达式例如:5+12*(3+5)/7- Returns:
- 计算结果
-
compare
public boolean compare(char cur, char peek) 利用ASCII码-40做下标去算术符号优先级- Parameters:
cur
- 下标peek
- peek- Returns:
- 优先级
-