The initial release of swift-bigint-gmp: GMPBigInt, an arbitrary-precision signed integer backed by GNU MP's mpz_t, behind the same Swift API as dankogai/swift-bignum's BigInt and dankogai/swift-bigint-javascriptcore's JSBigInt.
Highlights
- A full
SignedInteger:StaticBigIntliterals of any size, radix 2...36 strings, Swift division/shift semantics, two's-complementwords, exactBinaryInteger/BinaryFloatingPointconversions,Codable,Sendable. power(_:)andpower(_:mod:)(viampz_powm; negative exponent takes the modular inverse),greatestCommonDivisor(with:),squareRoot().- The whole primality kit with swift-bignum-identical verdicts: tri-state
isPrime,isSurelyPrime, BPSWisProbablePrime,millerRabinTest(base:),isLucasProbablePrime,isMersennePrime(Lucas-Lehmer),jacobiSymbol(_:),nextPrime/prevPrime, and the endlessGMPBigInt.primessequence. - macOS and Linux — anywhere GMP is; located via pkg-config (MacPorts:
PKG_CONFIG_PATH=/opt/local/lib/pkgconfig). - SwiftBigNumExample/:
Rational<GMPBigInt>andBigFloatOf<GMPBigInt>— swift-bignum'sBigRat/BigFloatmachinery on GMP digits, digit-for-digit identical output. - Benchmark.md: the fastest of the four libraries raced (JSCBigInt, attaswift/BigInt, swift-bignum) on every case but many-tiny-ops — up to 8× over JSCBigInt on huge mul/div, 20–60× over the pure-Swift bignums, 200–1000× on isqrt.
Usage
.package(url: "https://github.com/dankogai/swift-bigint-gmp.git", from: "0.0.1")🤖 Generated with Claude Code