Fixed bug "Convert hex string to decimal number #58" and made String init() 23 times faster with 60K digits. #60
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.
I fixed a few things including bug #58 with my merging of the different String init() functions. As a bonus, this init() is now about 23 times faster than it was and much easier to use. Overall, I was impressed by the speed of the various features with this one exception — so I had to fix it. 😉
I also fixed your magnitude function which now works correctly (at least how Apple intended).
BTW, I recommend removing the String.split since it was one major element responsible for slowing down the init().
I also noticed a bug with the random number creation where the bit sizes would be incorrect sometimes. This led me down a rabbit-hole in checking the true definition of the bitSize which is not defined how one would think. It is supposed to specify the actual size of the type on the underlying hardware — not the number of bits in a number as most people think. You can verify how Apple views this by performing the simple test: Int32(1).bitWidth = 32, not 1. Perhaps we need to define a new attribute like actualBitWidth.
I added some tags so that the Swift Package versions work correctly. The SPM does not like 'v's in front of the version numbers.
Overall, I really like the work you've done and may contribute some more bits and pieces.