-
Notifications
You must be signed in to change notification settings - Fork 155
[Sketch]Arbitrary-precision BigInt #84
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
96d41bc
Initial commit of BigInt
bc2f9fb
Use NumericShims for math functions
cb56525
Address PR feedback
ea2b6f8
BigInt no longer depends on NumericsShims
524dc69
slightly refactor LosslessStringConvertible initializer as per PR fee…
ac50a90
whoops
eceae6d
Update Sources/BigInt/BigInt.swift
b46dcf9
oops, change both occurrences of digitsAndDash
821fcbd
Update following suggestions from @benrimmington
cced27a
Missed a spot where things should be alphabetical
6785869
Update `LosslessStringConvertible` initializer
e490f1f
Explicitly implment hash(into:) per @benrimmington feedback
2863c44
[BigInt] Remove the isSigned property
benrimmington 38073d2
[BigInt] Move init(words:) and init(bitPattern:)
benrimmington 2f40de6
[BigInt] Move _isNegative and _digits properties
benrimmington dbf743b
[BigInt] Move the Equatable conformance
benrimmington a799618
[BigInt] Move the Hashable conformance
benrimmington 368caf5
[BigInt] Move the Comparable conformance
benrimmington 2419741
[BigInt] Move the CustomStringConvertible conformance
benrimmington 5db4a69
[BigInt] Move the LosslessStringConvertible conformance
benrimmington 5cb9b95
[BigInt] Move the ExpressibleByIntegerLiteral conformance
benrimmington cb5e7f3
[BigInt] Move the AdditiveArithmetic conformance
benrimmington 5b84051
[BigInt] Move the Numeric conformance
benrimmington 819ebd9
[BigInt] Move the SignedNumeric conformance
benrimmington 19d3491
[BigInt] Move the BinaryInteger initializers
benrimmington 11d5225
[BigInt] Move the BinaryInteger properties
benrimmington acd8568
[BigInt] Move the BinaryInteger operators
benrimmington 5be3b4e
[BigInt] Move the BinaryInteger methods
benrimmington d15400e
[BigInt] Add the Words typealias
benrimmington 831f06a
[BigInt] Add the MARK and TODO comments
benrimmington 3c91626
[BigInt] Update bitWidth and magnitude properties
benrimmington 4d7e4e9
[BigInt] Rename private _findQhat method
benrimmington 3a4cc1c
Merge pull request #1 from benrimmington/BigInt
7c6e2ce
Explicitly implement `public mutating func negate()`
036ab5f
Conform to Codable with default implementation
f6a3d2d
[BigIntTests] Add testMinMaxDescriptions() method
benrimmington 3cf0b0c
[BigInt] Update the LosslessStringConvertible init
benrimmington 8c37852
[BigInt] Update the Codable conformance
benrimmington 4ec520a
[BigIntTests] Update the testCodable() method
benrimmington c9d72fc
[BigIntTests] Trim trailing whitespace
benrimmington 1cb6938
[BigIntTests] Wrap to 80 characters
benrimmington b39dd05
[BigIntTests] Update the testExample() method
benrimmington 9ddc664
[BigIntTests] Remove messages from XCTAssert calls
benrimmington ddaf8be
Merge pull request #2 from benrimmington/BigInt
0e58379
explicitly call out TAOCP by Knuth
72f1cb3
Merge branch 'BigInt' of github.com:rothomp3/swift-numerics into BigInt
0b121fd
Fix failing tests (@benrimmington)
fd8049e
remove debugging code from test
830927e
[BigIntTests] Rewrite testMinMaxDescriptions()
benrimmington fe21235
[BigIntTests] Rename testRandomDescriptions()
benrimmington 7ae61f7
[BigIntTests] Update testLosslessStringConvertible
benrimmington 2410717
[BigInt] Update the SignedNumeric prefix operator
benrimmington a6ecb74
[BigIntTests] Update testRadicesAndNumerals()
benrimmington eab5a94
Merge pull request #3 from benrimmington/BigInt
1ddbbfe
Rename internal init as per @lorentey
7ca51a3
normalize words in the `BinaryInteger` bitPattern init
fac716f
Fix implementation of `<`
d36d9ce
Remove superfluous `CustomStringConvertible` impl
6f4374c
[BigIntTests] Add min and max Int1024 descriptions
benrimmington b03af80
[BigInt] Change `self = -self` to `self.negate()`
benrimmington e632de8
[BigIntTests] Add testFactorial()
benrimmington 49121f3
Merge pull request #4 from benrimmington/BigInt
937c292
[BigIntTests] Add testFloatingPoint_...() methods
benrimmington 1b733de
[BigInt] Fix initializers with BinaryFloatingPoint
benrimmington 506ea36
[BigIntTests] Update testFloatingPoint_random()
benrimmington 98023c3
[BigInt] Combine `*=` and `<<` into simpler `<<=`
benrimmington cfc2cd7
[BigIntTests] Add `measure {}` to testFactorial()
benrimmington 05a4598
[BigInt] Update signum(), add testSignum()
benrimmington 01c3096
[BigIntTests] Move the typealias of CLongDouble
benrimmington cfc63e8
[BigIntTests] Move testFloatingPoint_...() methods
benrimmington 0dee6d0
[BigIntTests] Move other test methods
benrimmington fc7b3bf
[BigIntTests] Update expected descriptions
benrimmington 4c42551
[BigIntTests] Use `fac(_:)` to test Strideable
benrimmington bf9afea
[BigIntTests] Add testFloatingPoint_signalingNaN()
benrimmington ffdaf86
[BigIntTests] Change `fac(BigInt(512))` to `BigInt.fac(512)`
benrimmington ca75d2d
[BigInt] Move `pow(_:_:)` into test-only extension
benrimmington 3501fa7
[BigInt] Restore precondition message for inf/nan
benrimmington ceee280
[BigIntTests] Don't use the CLongDouble typealias
benrimmington 6e85aa2
[BigInt] Revert the BinaryFloatingPoint conversion
benrimmington e41c631
Merge pull request #5 from benrimmington/BigInt
90d5ddd
Fix failing tests (@benrimminton: it turned out simple)
e3d01dd
First step to increasing test coverage
5919d3f
[BigIntTests] Use generic testBinaryFloatingPoint
benrimmington 1a29830
Merge pull request #6 from benrimmington/BigInt
7026eb4
more tests for division
9e1a1f5
Merge branch 'BigInt' of github.com:rothomp3/swift-numerics into BigInt
e4f5257
fix division
7d6e5cd
Clean up division a bit more
6e0f009
fix tests compiling on arm32
8790016
Normalize the remainder!
1995176
Another case where we'd get wrong negatives possibly
feeac39
Whoops, this is better
cc5f7e5
Apparently the @testable was only working in Xcode
caeeaaa
Another fix for arm32 and actually for anything with multi-word ints
52e7e70
Actual fix for multi-word integer types
aaeb902
Another fix for conversion of multi-word Ints
cd88f16
Fix two tests for arm32, should all pass now
b74c1ce
Fix `trailingZeroBitCount` as per @nixberg
5ea7711
Probably a slightly faster way to get trailingZeroBitCOunt
2f60891
[BigInt] Rename module
benrimmington 935eac1
Merge pull request #7 from benrimmington/BigInt
f11ce9b
Merge branch 'biginteger' into BigInt
stephentyrone File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
You don’t need to invoke
trailingZeroBitCount
on every word and then compare tobitWidth
. That’s just asking ifword == 0
.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.
That's true, I think. I'll take a look.
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.
Ok, updated to just explicitly check for
word == 0
, as I agree that's likely to be slightly faster.