BinaryInteger
protocol BinaryInteger : Hashable, Numeric, CustomStringConvertible, Strideable
-
Returns the result of raising
lhs
to the power ofrhs
, rounded to a representable value.Declaration
Swift
public static func ** (lhs: Self, rhs: Self) -> Self
-
Raises
lhs
to the power ofrhs
and stores the result inlhs
, rounded to a representable value.Declaration
Swift
public static func **= (lhs: inout Self, rhs: Self)
-
Returns the result of raising
base
to the power ofexponent
, rounded to a representable value (deprecated).Declaration
Swift
public static func pow(_ base: Self, _ exponent: Self) -> Self
-
Returns the square root of
x
, rounding toward zero. Ifx
is negative, a runtime error may occur.Declaration
Swift
public static func sqrt(_ x: Self) -> Self
-
Returns the cube root of
x
, rounding toward zero.Declaration
Swift
public static func cbrt(_ x: Self) -> Self
-
Returns the greatest common divisor of
a
andb
.Declaration
Swift
public static func gcd(_ a: Self, _ b: Self) -> Self
-
Returns the least common multiple of
a
andb
.Declaration
Swift
public static func lcm(_ a: Self, _ b: Self) -> Self
-
Returns the greatest common divisor of
a
andb
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)
-
Returns the least common multiple of
a
andb
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)
-
Returns the high and low parts of the least common multiple of
a
andb
computed using full-width arithmetic.Declaration
Swift
public static func lcmFullWidth(_ a: Self, _ b: Self) -> (high: Self, low: Self.Magnitude)
-
Creates a new binary integer from the given rational value, if it can be represented exactly.
If
source
is not representable exactly, the result isnil
.Declaration
Swift
public init?<U>(exactly source: Rational<U>)
Parameters
source
-
A rational value to convert to a binary integer.
-
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.