-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
143: Count big bits in u64 instead of usize r=cuviper a=cuviper A 32-bit target _could_ create a giant `BigUint` over 2²⁹ bytes = 512MB, not that this would be computationally useful, but that value would have more than `usize::MAX` bits. To avoid that possibility of overflow, we can better represent bit counts in `u64`. For 64-bit targets, a `BigUint` over 2⁶¹ bytes is not realistic. This changes the public API in the return values of `bits()` and `trailing_zeros()`, as well as the `bit_size` parameter of `RandBigInt` and `RandomBits`. Trying to randomize an absurd size will naturally cause a capacity overflow, just as if you'd made a huge `Vec`. Co-authored-by: Josh Stone <cuviper@gmail.com>
- Loading branch information
Showing
10 changed files
with
86 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.