Skip to content
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

[Sketch]Arbitrary-precision BigInt #84

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
whoops
  • Loading branch information
Robert Thompson committed Dec 30, 2019
commit ac50a90a6068e47134ffc5ddeee65c04a415a305
2 changes: 1 addition & 1 deletion Sources/BigInt/BigInt.swift
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ public struct BigInt: BinaryInteger, SignedNumeric, SignedInteger, CustomStringC
guard let firstCharacter = description.first else { return nil }

var description = description
let isNegative: Bool
var isNegative: Bool = false
if description.count > 1 {
if firstCharacter == "-" {
isNegative = true