Ben Rimmington
8c378528de
[BigInt] Update the Codable conformance
2020-01-15 00:59:46 +00:00
Ben Rimmington
3cf0b0cf74
[BigInt] Update the LosslessStringConvertible init
...
This performs 6x faster (measured with a 1000-digit string).
But it doesn't fix the testMinMaxDescriptions() failures.
2020-01-15 00:47:04 +00:00
Robert Thompson
036ab5fe94
Conform to Codable with default implementation
...
Since we have only a single stored property which itself already
conforms to `Codable`, there's no need to go down the rabbit hole of
explicitly implementing it. If someone wants to do it to produce a more
human-readable JSON (eg, as a string instead of an array of integers),
then you're welcome to.
2020-01-14 15:07:08 -05:00
Robert Thompson
7c6e2ce0d8
Explicitly implement public mutating func negate()
...
As per the TODO put in by @benrimmington. I'm not 100% sure this is
actually better than the default implementation provided by
`SignedNumeric`, but there's a chance it is.
2020-01-14 15:00:38 -05:00
Ben Rimmington
4d7e4e9b97
[BigInt] Rename private _findQhat method
2020-01-14 04:44:44 +00:00
Ben Rimmington
3c916262e0
[BigInt] Update bitWidth and magnitude properties
2020-01-14 02:46:47 +00:00
Ben Rimmington
831f06ac78
[BigInt] Add the MARK and TODO comments
2020-01-14 02:44:38 +00:00
Ben Rimmington
d15400e6ab
[BigInt] Add the Words typealias
2020-01-14 02:39:59 +00:00
Ben Rimmington
5be3b4e526
[BigInt] Move the BinaryInteger methods
2020-01-14 02:38:53 +00:00
Ben Rimmington
acd8568864
[BigInt] Move the BinaryInteger operators
2020-01-14 02:36:23 +00:00
Ben Rimmington
11d5225f3b
[BigInt] Move the BinaryInteger properties
2020-01-14 02:26:50 +00:00
Ben Rimmington
19d3491df4
[BigInt] Move the BinaryInteger initializers
2020-01-14 02:25:37 +00:00
Ben Rimmington
819ebd90c4
[BigInt] Move the SignedNumeric conformance
2020-01-14 02:16:00 +00:00
Ben Rimmington
5b84051f2a
[BigInt] Move the Numeric conformance
2020-01-14 02:14:30 +00:00
Ben Rimmington
cb5e7f3c7a
[BigInt] Move the AdditiveArithmetic conformance
2020-01-14 02:09:45 +00:00
Ben Rimmington
5cb9b95ce8
[BigInt] Move the ExpressibleByIntegerLiteral conformance
2020-01-14 02:05:42 +00:00
Ben Rimmington
5db4a69e57
[BigInt] Move the LosslessStringConvertible conformance
2020-01-14 02:04:16 +00:00
Ben Rimmington
2419741a7c
[BigInt] Move the CustomStringConvertible conformance
2020-01-14 02:00:12 +00:00
Ben Rimmington
368caf5b3f
[BigInt] Move the Comparable conformance
2020-01-14 01:58:03 +00:00
Ben Rimmington
a799618103
[BigInt] Move the Hashable conformance
2020-01-14 01:56:43 +00:00
Ben Rimmington
dbf743b314
[BigInt] Move the Equatable conformance
2020-01-14 01:54:58 +00:00
Ben Rimmington
2f40de6195
[BigInt] Move _isNegative and _digits properties
2020-01-14 01:52:01 +00:00
Ben Rimmington
38073d2ab5
[BigInt] Move init(words:) and init(bitPattern:)
2020-01-14 01:49:26 +00:00
Ben Rimmington
2863c44182
[BigInt] Remove the isSigned property
2020-01-14 01:42:43 +00:00
Robert Thompson
e490f1fc66
Explicitly implment hash(into:) per @benrimmington feedback
...
Technically, I believe the auto-generated implementation was already
doing exactly this, since `words` is the only stored property of
`BigInt`. However, it rarely hurts to be explicit.
2020-01-13 14:45:48 -05:00
Robert Thompson
67858690eb
Update LosslessStringConvertible initializer
...
as per further suggestions from @Wildchild9, adding in the removing
leading zeros part I missed.
2019-12-30 16:01:04 -05:00
Robert Thompson
821fcbd6a4
Update following suggestions from @benrimmington
...
Includes reformatting to use 2-space indentation and the correct file
headers, among other simplifications.
2019-12-30 15:46:18 -05:00
Robert Thompson
b46dcf96c6
oops, change both occurrences of digitsAndDash
2019-12-30 15:13:26 -05:00
Robert Thompson and Ben Rimmington
eceae6d7bd
Update Sources/BigInt/BigInt.swift
...
As per benrimmington's excellent suggestion
Co-Authored-By: Ben Rimmington <me@benrimmington.com >
2019-12-30 15:12:20 -05:00
Robert Thompson
ac50a90a60
whoops
2019-12-30 10:44:48 -05:00
Robert Thompson
524dc69ae1
slightly refactor LosslessStringConvertible initializer as per PR feedback
2019-12-30 10:41:40 -05:00
Robert Thompson
cb56525312
Address PR feedback
...
Eliminate unnecessary math function calls, and also handle floating
point edge cases better.
2019-12-30 10:33:00 -05:00
Robert Thompson
bc2f9fb7c6
Use NumericShims for math functions
2019-12-30 10:33:00 -05:00
Robert Thompson
96d41bcf9f
Initial commit of BigInt
2019-12-30 10:33:00 -05:00