Commit Graph
47 Commits
Author SHA1 Message Date
Gwynne Raskind 349fdf1e01 Add preliminary version of BigUInt 2023-12-26 11:12:49 -06:00
Ben Rimmington 2f60891517 [BigInt] Rename module
See also: apple/swift-numerics#97
2020-04-24 12:39:49 +01:00
Robert Thompson b74c1ce133 Fix trailingZeroBitCount as per @nixberg
Also add a couple tests for it
2020-02-14 16:23:37 -05:00
Robert Thompson cd88f161eb Fix two tests for arm32, should all pass now 2020-01-29 10:48:46 -05:00
Robert Thompson cc5f7e5d18 Apparently the @testable was only working in Xcode 2020-01-28 17:55:39 -05:00
Robert Thompson 87900161d6 Normalize the remainder! 2020-01-28 17:36:55 -05:00
Robert Thompson 6e0f0094dc fix tests compiling on arm32 2020-01-28 16:09:32 -05:00
Robert Thompson 7d6e5cda3e Clean up division a bit more 2020-01-28 16:02:30 -05:00
Robert Thompson 9e1a1f5e8a Merge branch 'BigInt' of github.com:rothomp3/swift-numerics into BigInt 2020-01-27 12:31:33 -05:00
Robert Thompson 7026eb4085 more tests for division 2020-01-27 12:31:26 -05:00
Ben Rimmington 5919d3f48f [BigIntTests] Use generic testBinaryFloatingPoint 2020-01-27 15:17:43 +00:00
Robert Thompson e3d01dd680 First step to increasing test coverage 2020-01-22 10:16:01 -05:00
Ben Rimmington ceee280ebe [BigIntTests] Don't use the CLongDouble typealias 2020-01-21 18:09:39 +00:00
Ben Rimmington ca75d2d124 [BigInt] Move pow(_:_:) into test-only extension 2020-01-21 16:24:51 +00:00
Ben Rimmington ffdaf86868 [BigIntTests] Change fac(BigInt(512)) to BigInt.fac(512) 2020-01-21 13:30:21 +00:00
Ben Rimmington bf9afea2eb [BigIntTests] Add testFloatingPoint_signalingNaN() 2020-01-21 08:36:48 +00:00
Ben Rimmington 4c425513cd [BigIntTests] Use fac(_:) to test Strideable 2020-01-20 13:05:49 +00:00
Ben Rimmington fc7b3bf44f [BigIntTests] Update expected descriptions 2020-01-20 11:48:46 +00:00
Ben Rimmington 0dee6d0927 [BigIntTests] Move other test methods 2020-01-20 11:05:12 +00:00
Ben Rimmington cfc63e8adc [BigIntTests] Move testFloatingPoint_...() methods 2020-01-20 10:30:16 +00:00
Ben Rimmington 01c30961ef [BigIntTests] Move the typealias of CLongDouble 2020-01-19 20:31:22 +00:00
Ben Rimmington 05a45984d9 [BigInt] Update signum(), add testSignum() 2020-01-19 19:48:07 +00:00
Ben Rimmington cfc2cd7c97 [BigIntTests] Add measure {} to testFactorial() 2020-01-19 12:32:11 +00:00
Ben Rimmington 506ea36331 [BigIntTests] Update testFloatingPoint_random() 2020-01-19 09:37:20 +00:00
Ben Rimmington 937c292898 [BigIntTests] Add testFloatingPoint_...() methods
The testFloatingPoint_greatestFiniteMagnitude() method currently fails.
2020-01-18 19:38:05 +00:00
Ben Rimmington e632de88c4 [BigIntTests] Add testFactorial() 2020-01-17 13:51:21 +00:00
Ben Rimmington 6f4374cd99 [BigIntTests] Add min and max Int1024 descriptions 2020-01-17 07:32:52 +00:00
Robert Thompson d36d9ce02e Remove superfluous CustomStringConvertible impl 2020-01-16 17:08:52 -05:00
Robert Thompson fac716fdb2 Fix implementation of <
Previously, all BigInts were less than themselves. This is no longer
true. Discovered thanks to @lorentey and @benrimmington re: discussion
on explicit implementation of `!=`.
2020-01-16 15:15:37 -05:00
Ben Rimmington a6ecb7442a [BigIntTests] Update testRadicesAndNumerals() 2020-01-16 14:50:19 +00:00
Ben Rimmington 7ae61f775b [BigIntTests] Update testLosslessStringConvertible 2020-01-16 13:04:39 +00:00
Ben Rimmington fe212356fd [BigIntTests] Rename testRandomDescriptions() 2020-01-16 12:40:02 +00:00
Ben Rimmington 830927ecbb [BigIntTests] Rewrite testMinMaxDescriptions() 2020-01-16 12:19:33 +00:00
Robert Thompson fd8049e481 remove debugging code from test 2020-01-15 15:25:11 -05:00
Robert Thompson 0b121fd774 Fix failing tests (@benrimmington)
We were not correctly handling the case where two single-word operands
added up to a number > Int.max. Also, negate (and `-`) was not removing
excess words, resulting in identical numbers not comparing equal!
2020-01-15 15:13:58 -05:00
Ben Rimmington 9ddc664ef1 [BigIntTests] Remove messages from XCTAssert calls 2020-01-15 06:51:21 +00:00
Ben Rimmington b39dd05db3 [BigIntTests] Update the testExample() method 2020-01-15 06:44:41 +00:00
Ben Rimmington 1cb69383a5 [BigIntTests] Wrap to 80 characters 2020-01-15 03:53:16 +00:00
Ben Rimmington c9d72fc3ae [BigIntTests] Trim trailing whitespace 2020-01-15 03:34:14 +00:00
Ben Rimmington 4ec520a726 [BigIntTests] Update the testCodable() method
Top-level JSON fragments might fail on Linux, so encode Range<BigInt> instead.

<https://bugs.swift.org/browse/SR-6163>
2020-01-15 03:30:50 +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
Ben Rimmington f6a3d2d4e4 [BigIntTests] Add testMinMaxDescriptions() method
This currently fails for:

BigInt(Int64.min) - 2
BigInt(Int64.min) - 1
BigInt(Int64.max) + 1
BigInt(Int64.max) + 2
2020-01-15 00:17:17 +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
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 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