SignedNumberRepresentation
public enum SignedNumberRepresentation
Represents a method to encode signed integers in a binary format.
-
Signed magnitude representation.
Declaration
Swift
case signMagnitude
-
One’s complement representation of negative integers.
Declaration
Swift
case oneComplementNegatives
-
Two’s complement representation of negative integers.
Declaration
Swift
case twoComplementNegatives
-
Biased representation with a custom
bias
.Declaration
Swift
case biased(bias: Int)
-
Base (radix) -2 representation.
Declaration
Swift
case radixNegativeTwo
-
Returns a minimum signed integer that is possible to represent in a binary format within
bitsCount
bits using the current representation.Precondition
ParameterbitsCount
must be greater than zero.Precondition
For theSignedNumberRepresentation.biased
representation, thebias
must be non-negative.Declaration
Swift
public func minRepresentableNumber(bitsCount: Int) -> Int
-
Returns a maximum signed integer that is possible to represent in a binary format within
bitsCount
bits using the current representation.Precondition
ParameterbitsCount
must be greater than zero.Precondition
For theSignedNumberRepresentation.biased
representation, thebias
must be non-negative.Declaration
Swift
public func maxRepresentableNumber(bitsCount: Int) -> Int