Skip to content

Commit

Permalink
Expand some comments on DoubleWidth basic properties and inits.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentyrone committed Nov 3, 2021
1 parent 84044a8 commit cdb092b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions Sources/_TestSupport/DoubleWidth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,30 @@ public struct DoubleWidth<Base : FixedWidthInteger> {
public typealias Low = Base.Magnitude

internal var _storage: (low: Low, high: High)
}

/// The high part of the value.
extension DoubleWidth {
/// The "high word" of this value.
///
/// Equivalent to `Base(self >> Base.bitWidth)`.
public var high: High {
return _storage.high
}

/// The low part of the value.
/// The "low word" of the value.
///
/// Equivalent to`Base.Magnitude(truncatingIfNecessary: self)`.
public var low: Low {
return _storage.low
}

/// Creates a new instance from the given tuple of high and low parts.
///
/// Equivalent to
/// ```
/// DoubleWidth<Base>(high) << Base.bitWidth + DoubleWidth<Base>(low)
/// ```
///
/// - Parameter value: The tuple to use as the source of the new instance's
/// high and low parts.
public init(_ value: (high: High, low: Low)) {
Expand All @@ -79,10 +90,18 @@ public struct DoubleWidth<Base : FixedWidthInteger> {
//
// For that reason, we'll include an internal initializer that takes two
// separate arguments.

/// Creates a new instance from the given tuple of high and low parts.
///
/// Equivalent to
/// ```
/// DoubleWidth<Base>(high) << Base.bitWidth + DoubleWidth<Base>(low)
/// ```
internal init(_ _high: High, _ low: Low) {
self.init((_high, low))
}


/// Zero.
public init() {
self.init(0, 0)
}
Expand Down

0 comments on commit cdb092b

Please sign in to comment.