public void removeBit() {
        if (length == 0) {
            throw new IllegalStateException("no bits to remove");
        }

        // Shift the bits one place to the right, losing the rightmost bit.
        bits = bits >> 1;

        length--;
    }