Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

非浮点型科学计数解析异常处理 #195

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jiwenxing
Copy link

类似 2e2 此类非浮点类型的科学计数写法解析时会抛 NumberFormatException,处理后可以正常解析,详见单测

Caused by: java.lang.NumberFormatException: For input string: "2e2"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:589)
at java.lang.Long.parseLong(Long.java:631)
at com.ql.util.express.parse.ExpressParse.transferWord2ExpressNode(ExpressParse.java:181)
at com.ql.util.express.parse.ExpressParse.parse(ExpressParse.java:373)
at com.ql.util.express.parse.ExpressParse.parse(ExpressParse.java:367)
at com.ql.util.express.parse.ExpressParse.parse(ExpressParse.java:340)
at com.ql.util.express.ExpressRunner.parseInstructionSet(ExpressRunner.java:700)
... 24 more

@CLAassistant
Copy link

CLAassistant commented May 12, 2022

CLA assistant check
All committers have signed the CLA.

@jiwenxing jiwenxing force-pushed the scientific-optimism branch from db36124 to abce074 Compare May 13, 2022 02:35
@DQinYuan DQinYuan requested a review from pymBupt May 15, 2022 08:09
@@ -172,7 +172,12 @@ public List<ExpressNode> transferWord2ExpressNode(ExpressPackage rootExpressPack
tempWord = tempWord.substring(0, tempWord.length() - 1);
objectValue = Long.valueOf(tempWord);
} else {
long tempLong = Long.parseLong(tempWord);
long tempLong;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个地方转成double可能更合适,基于一下两点:

  1. 2e-2,这个是0.02,转成long直接是0了
  2. 科学计数法标识的数值可以很大,超过long的最大值。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants