multprec.cpp: Simplify with _Unsigned128#5473
Merged
StephanTLavavej merged 2 commits intomicrosoft:mainfrom May 10, 2025
Merged
multprec.cpp: Simplify with _Unsigned128#5473StephanTLavavej merged 2 commits intomicrosoft:mainfrom
multprec.cpp: Simplify with _Unsigned128#5473StephanTLavavej merged 2 commits intomicrosoft:mainfrom
Conversation
AlexGuteniev
reviewed
May 7, 2025
AlexGuteniev
reviewed
May 7, 2025
This comment was marked as resolved.
This comment was marked as resolved.
zacklj89
approved these changes
May 8, 2025
Member
Author
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
StephanTLavavej
added a commit
to StephanTLavavej/STL
that referenced
this pull request
May 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup to #5436, which reimplemented
linear_congruential_enginein<random>by using our modern_Unsigned128. This PR shrinks our separately compiled, now-retained-for-bincompatmultprec.cppby also using_Unsigned128. Ordinarily we don't put a lot of effort into simplifying retained-for-bincompat code because the benefit is low and the risk is unnecessary. In this case, it's worth the risk because this fixes #1008 by removing squirrelly code that needed an/analyzesuppression. (Being/analyze-clean is very important now, and keeping suppressions around in our codebase is a minor debt.)My new comments do a hopefully better job than before of explaining
_MP_arr's representation, and the assumptions behind the various functions. I am aiming for simplicity here, not micro-optimizations; e.g._MP_Rem()is computing modulo a 64-bit value, so only the lower 64 bits will be non-zero, but I'm still going through the generalassign_mp_from_u128()helper function.Retained-for-bincompat code isn't something that we expend effort on testing (the idea is that we don't mess with it and it keeps working). In this case, I performed manual randomized testing. I wrote a test case to generate random values, subject to the conditions in
linear_congruential_engine, and compared not only the ultimate output but also the intermediate_MP_arrcontents. I compared the new implementation (after building the STL and runningset_environment.bat, of course) to a copy of the old classic implementation, for 12.8 billion trials, and everything agreed.Click to expand test case: