Function regroupBits

  • Given an array of integers, regroup bits from sourceWordLength to resultWordLength, returning a new array of integers between 0 and toWordLength^2.

    Note, if bin is within the range of sourceWordLength and padding is true, this method will never error.

    A.K.A. convertbits


    • __namedParameters: {
          allowPadding?: boolean;
          bin: number[] | Uint8Array;
          resultWordLength: number;
          sourceWordLength: number;
      • Optional allowPadding?: boolean

        Whether to allow the use of padding for bin values where the provided number of bits cannot be directly mapped to an equivalent result array (remaining bits are filled with 0), defaults to true

      • bin: number[] | Uint8Array

        An array of numbers representing the bits to regroup. Each item must be a number within the range of sourceWordLength.

      • resultWordLength: number

        The bit-length of each number in the desired result array, e.g. to regroup bits into 4-bit numbers, use 4 (must be a positive integer)

      • sourceWordLength: number

        The bit-length of each number in bin, e.g. to regroup bits from a Uint8Array, use 8 (must be a positive integer)

    Returns number[] | integerOutOfRange | hasDisallowedPadding | requiresDisallowedPadding

Generated using TypeDoc