-
Notifications
You must be signed in to change notification settings - Fork 409
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
Fix function mod
decimal scale overflow
#2462
Conversation
else | ||
// assert that negation of std::numeric_limits<From>::min() will not result in overflow. | ||
// TODO: find credible source that describes numeric limits of boost multiprecision *checked* integers. | ||
static_assert(-std::numeric_limits<From>::max() == std::numeric_limits<From>::min()); |
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.
interestring, I thought -std::numeric_limits<From>::max()
should be larger than std::numeric_limits<From>::min()
by 1.
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.
I was also surprised by the fact. I guess Boost made a deliberate decision on checked fixed precision integers. But I didn't find any evidence in Boost multiprecision doc.
By contrast, Boost says unchecked integers use 2's complement representation in their documents: https://www.boost.org/doc/libs/1_76_0/libs/multiprecision/doc/html/boost_multiprecision/tut/ints/cpp_int.html
@fuzhe1989, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: tiflash(slack). |
/run-all-tests |
/merge |
/run-all-tests |
cherry pick to release-5.0 in PR #2608 |
cherry pick to release-5.1 in PR #2609 |
What problem does this PR solve?
Problem Summary: #2402 (issue #2318) will overflow in decimal modulo.
What is changed and how it works?
What's Changed: This PR fixes the issue by assign modulo operation to
need_promote_type
inDecimalBinaryOperation
.Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note
MOD(N, M)
.