-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
types: floatStrToIntStr will failed in some case such as the param is +999.9999e2 #11376
Conversation
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #11376 +/- ##
================================================
+ Coverage 81.3776% 82.1068% +0.7291%
================================================
Files 424 425 +1
Lines 90939 94360 +3421
================================================
+ Hits 74004 77476 +3472
+ Misses 11620 11488 -132
- Partials 5315 5396 +81 |
/run-all-tests |
/run-all-tests |
@H-ZeX please follow https://github.com/pingcap/tidb/blob/master/CONTRIBUTING.md to refine the PR title. |
+999.9999e2
+999.9999e2
+999.9999e2
+999.9999e2
types/convert.go
Outdated
func roundIntStr(numNextDot byte, intStr string) string { | ||
if numNextDot < '5' { | ||
return intStr | ||
} | ||
retStr := []byte(intStr) | ||
for i := len(intStr) - 1; i >= 0; i-- { | ||
if !isDigit(intStr[i]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here i
must be 0 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, but this a valid int string, so we needn't to check whether it is 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i
must be 0, can we move if !isDigit(intStr[i])
logic to outside the for loop
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Signed-off-by: H-ZeX <hzx20112012@gmail.com>
…nto fix-bug-of-floatStrToIntStr
ping @crazycs520 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/run-all-tests |
@H-ZeX merge failed. |
cherry pick to release-2.1 failed |
cherry pick to release-3.0 failed |
What problem does this PR solve?
In the origin
floatStrToIntStr
, it may fail in some casenumNextDot
is+/-
in some case+999.9999e2
(return,00000
) because theroundIntStr
can not handler+/-
correctly.Tests
Related changes