-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format/Parse binary from/to BigInteger (#85392)
* Initial draft commit: add FormatBigIntegerToBin(). * Fix comment: use '?:' to assign ValueStringBuilder variable to make it 'unsafe to return' so that can assign stackalloced. * Refine FormatBigIntegerToBin(); and consider chars overflow scenario. * Update Format code for final binary format definition. * Refine FormatBigIntegerToBin(). * consider case where output is span * Turn to use try..finally to return array pool. * Initial add method BinNumberToBigInteger(). * Update FormatProvider.Number.cs to support AllowBinarySpecifier. * Use BinNumberToBigInteger(). * Add tests of Format. * Add tests of Parse(). * Improve Format(): use ValueStringBuilder just as wrapper for destination span, so to save extra buffer allocation and copy in ValueStringBuilder. * Fix comment: use ch == '0' || ch == '1' * Fix comment: refactor ParseNumber() to extract common abstract operations for previous Hex and new Binary. * Fix comment: refine naming; make BinNumberToBigInteger() general pattern similar as HexNumberToBigInteger's * Fix comment: use internal 'kcbitUint'. * Fix comment: rename 'Bin' method names to 'Binary' ones; remove unnecessary Slice().
- Loading branch information
1 parent
529f60e
commit 71d6476
Showing
5 changed files
with
521 additions
and
16 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
Oops, something went wrong.