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

    Parameter bitsCount must be greater than zero.

    Precondition

    For the SignedNumberRepresentation.biased representation, the bias 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

    Parameter bitsCount must be greater than zero.

    Precondition

    For the SignedNumberRepresentation.biased representation, the bias must be non-negative.

    Declaration

    Swift

    public func maxRepresentableNumber(bitsCount: Int) -> Int