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
bitsCountbits using the current representation.Precondition
ParameterbitsCountmust be greater than zero.Precondition
For theSignedNumberRepresentation.biasedrepresentation, thebiasmust 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
bitsCountbits using the current representation.Precondition
ParameterbitsCountmust be greater than zero.Precondition
For theSignedNumberRepresentation.biasedrepresentation, thebiasmust be non-negative.Declaration
Swift
public func maxRepresentableNumber(bitsCount: Int) -> Int
View on GitHub
SignedNumberRepresentation Enumeration Reference