NumericAnnex Reference (100% documented)

View on GitHub

Install in Dash

BinaryInteger

protocol BinaryInteger : Hashable, Numeric, CustomStringConvertible, Strideable
Topics

Exponentiation

  • **(_:_:)

    Returns the result of raising lhs to the power of rhs, rounded to a representable value.

    Declaration

    Swift

    public static func ** (lhs: Self, rhs: Self) -> Self
  • **=(_:_:)

    Raises lhs to the power of rhs and stores the result in lhs, rounded to a representable value.

    Declaration

    Swift

    public static func **= (lhs: inout Self, rhs: Self)
  • pow(_:_:)

    Returns the result of raising base to the power of exponent, rounded to a representable value (deprecated).

    Declaration

    Swift

    public static func pow(_ base: Self, _ exponent: Self) -> Self

Square Root

  • sqrt(_:)

    Returns the square root of x, rounding toward zero. If x is negative, a runtime error may occur.

    Declaration

    Swift

    public static func sqrt(_ x: Self) -> Self

Cube Root

  • cbrt(_:)

    Returns the cube root of x, rounding toward zero.

    Declaration

    Swift

    public static func cbrt(_ x: Self) -> Self

Factoring

  • gcd(_:_:)

    Returns the greatest common divisor of a and b.

    Declaration

    Swift

    public static func gcd(_ a: Self, _ b: Self) -> Self
  • lcm(_:_:)

    Returns the least common multiple of a and b.

    Declaration

    Swift

    public static func lcm(_ a: Self, _ b: Self) -> Self

Factoring (Fixed-Width)

  • gcdReportingOverflow(_:_:)

    Returns the greatest common divisor of a and b and a flag to indicate whether overflow occurred during the operation.

    Declaration

    Swift

    public static func gcdReportingOverflow(_ a: Self, _ b: Self)
        -> (partialValue: Self, overflow: Bool)
  • lcmReportingOverflow(_:_:)

    Returns the least common multiple of a and b and a flag to indicate whether overflow occurred during the operation.

    Declaration

    Swift

    public static func lcmReportingOverflow(_ a: Self, _ b: Self)
        -> (partialValue: Self, overflow: Bool)
  • lcmFullWidth(_:_:)

    Returns the high and low parts of the least common multiple of a and b computed using full-width arithmetic.

    Declaration

    Swift

    public static func lcmFullWidth(_ a: Self, _ b: Self)
        -> (high: Self, low: Self.Magnitude)

Initializers

  • init(exactly:)

    Creates a new binary integer from the given rational value, if it can be represented exactly.

    If source is not representable exactly, the result is nil.

    Declaration

    Swift

    public init?<U>(exactly source: Rational<U>)
    Parameters
    source

    A rational value to convert to a binary integer.

  • init(_:)

    Creates a new binary integer from the given rational value, rounding toward zero.

    If source is outside the bounds of this type after rounding toward zero, a runtime error may occur.

    Declaration

    Swift

    public init<U>(_ source: Rational<U>)
    Parameters
    source

    A rational value to convert to a binary integer.