-=(_:_:)
Subtract b
from a
in place.
static func -= (a: inout BigInt, b: BigInt)
Subtract b
from a
in place.
static func -= (a: inout BigInt, b: BigInt)
import BigInt
struct BigInt
An arbitary precision signed integer type, also known as a “big integer”.
init()
init(_ data: Data)
Initializes an integer from the bits stored inside a piece of Data
. The data is assumed to be in network (big-endian) byte order with a first byte to represent the sign (0 for positive, 1 for negative)
init(_ buffer: UnsafeRawBufferPointer)
Initialize a BigInt from bytes accessed from an UnsafeRawBufferPointer, where the first byte indicates sign (0 for positive, 1 for negative)
init<T>(_ source: T) where T : BinaryFloatingPoint
init<T>(_ source: T) where T : BinaryInteger
init(_ integer: BigUInt)
Initializes a new signed big integer with the same value as the specified unsigned big integer.
init?<S>(_ text: S, radix: Int = 10) where S : StringProtocol
Initialize a big integer from an ASCII representation in a given radix. Numerals above 9
are represented by letters from the English alphabet.
init<T>(clamping source: T) where T : BinaryInteger
init?(exactly source: Decimal)
init?<T>(exactly source: T) where T : BinaryFloatingPoint
init?<T>(exactly source: T) where T : BinaryInteger
init(extendedGraphemeClusterLiteral value: String)
Initialize a new big integer from an extended grapheme cluster. The cluster must consist of a decimal digit.
init(from decoder: Decoder) throws
init(integerLiteral value: Int64)
Initialize a new big integer from an integer literal.
init(sign: Sign, magnitude: BigUInt)
Initializes a new big integer with the provided absolute number and sign flag.
init(stringLiteral value: StringLiteralType)
Initialize a new big integer from a decimal number represented by a string literal of arbitrary length. The string must contain only decimal digits.
init?(truncating source: Decimal)
init<T>(truncatingIfNeeded source: T) where T : BinaryInteger
init(unicodeScalarLiteral value: UnicodeScalar)
Initialize a new big integer from a Unicode scalar. The scalar must represent a decimal digit.
init<S>(words: S) where S : Sequence, S.Element == UInt
static var isSigned: Bool { get }
var bitWidth: Int { get }
var debugDescription: String { get }
Return the decimal representation of this integer.
var description: String { get }
Return the decimal representation of this integer.
var isZero: Bool { get }
Return true iff this integer is zero.
var magnitude: BigUInt
The absolute value of this integer.
var playgroundDescription: Any { get }
Return the playground quick look representation of this integer.
var sign: Sign
True iff the value of this integer is negative.
var trailingZeroBitCount: Int { get }
var words: Words { get }
static func % (a: BigInt, b: BigInt) -> BigInt
Divide a
by b
and return the remainder. The result has the same sign as a
.
static func %= (a: inout BigInt, b: BigInt)
Divide a
by b
storing the remainder in a
.
static func & (lhs: inout BigInt, rhs: BigInt) -> BigInt
static func &<< (left: BigInt, right: BigInt) -> BigInt
static func &<<= (left: inout BigInt, right: BigInt)
static func &= (lhs: inout BigInt, rhs: BigInt)
static func &>> (left: BigInt, right: BigInt) -> BigInt
static func &>>= (left: inout BigInt, right: BigInt)
static func * (a: BigInt, b: BigInt) -> BigInt
Multiply a
with b
and return the result.
static func *= (a: inout BigInt, b: BigInt)
Multiply a
with b
in place.
static func + (a: BigInt, b: BigInt) -> BigInt
Add a
to b
and return the result.
static func += (a: inout BigInt, b: BigInt)
Add b
to a
in place.
static func - (a: BigInt, b: BigInt) -> BigInt
Subtract b
from a
and return the result.
static func / (a: BigInt, b: BigInt) -> BigInt
Divide a
by b
and return the quotient. Traps if b
is zero.
static func /= (a: inout BigInt, b: BigInt)
Divide a
by b
storing the quotient in a
.
static func < (a: BigInt, b: BigInt) -> Bool
Return true iff a
is less than b
.
static func << <Other>(lhs: BigInt, rhs: Other) -> BigInt where Other : BinaryInteger
static func <<= <Other>(lhs: inout BigInt, rhs: Other) where Other : BinaryInteger
static func == (a: BigInt, b: BigInt) -> Bool
Return true iff a
is equal to b
.
static func >> <Other>(lhs: BigInt, rhs: Other) -> BigInt where Other : BinaryInteger
static func >>= <Other>(lhs: inout BigInt, rhs: Other) where Other : BinaryInteger
static func ^ (lhs: inout BigInt, rhs: BigInt) -> BigInt
static func ^= (lhs: inout BigInt, rhs: BigInt)
static func | (lhs: inout BigInt, rhs: BigInt) -> BigInt
static func |= (lhs: inout BigInt, rhs: BigInt)
static func ~ (x: BigInt) -> BigInt
func advanced(by n: Stride) -> BigInt
Returns self + n
.
func distance(to other: BigInt) -> Stride
Returns other - self
.
func encode(to encoder: Encoder) throws
func greatestCommonDivisor(with b: BigInt) -> BigInt
Returns the greatest common divisor of a
and b
.
func hash(into hasher: inout Hasher)
Append this BigInt
to the specified hasher.
func inverse(_ modulus: BigInt) -> BigInt?
Returns the multiplicative inverse of this integer in modulo modulus
arithmetic, or nil
if there is no such number.
func isPrime(rounds: Int = 10) -> Bool
Returns true if this integer is probably prime. Returns false if this integer is definitely not prime.
func isStrongProbablePrime(_ base: BigInt) -> Bool
Returns true iff this integer passes the strong probable prime test for the specified base.
func modulus(_ mod: BigInt) -> BigInt
Return the result of a
mod b
. The result is always a nonnegative integer that is less than the absolute value of b
.
mutating func negate()
func power(_ exponent: Int) -> BigInt
Returns this integer raised to the power exponent
.
func power(_ exponent: BigInt, modulus: BigInt) -> BigInt
Returns the remainder of this integer raised to the power exponent
in modulo arithmetic under modulus
.
func quotientAndRemainder(dividingBy y: BigInt) -> (quotient: BigInt, remainder: BigInt)
Divide this integer by y
and return the resulting quotient and remainder.
func serialize() -> Data
Return a Data
value that contains the base-256 representation of this integer, in network (big-endian) byte order and a prepended byte to indicate the sign (0 for positive, 1 for negative)
func serializeToBuffer() -> UnsafeRawBufferPointer
Return a Data
value that contains the base-256 representation of this integer, in network (big-endian) byte order and a prepended byte to indicate the sign (0 for positive, 1 for negative)
func signum() -> BigInt
Returns -1
if this value is negative and 1
if it’s positive; otherwise, 0
.
func squareRoot() -> BigInt
Returns the integer square root of a big integer; i.e., the largest integer whose square isn’t greater than value
.
enum Sign
struct Words
typealias Magnitude = BigUInt
typealias Stride = BigInt
typealias Word = BigUInt.Word
The type representing a digit in BigInt
’s underlying number system.