Unary operation: SignExtend

        :param new_length: New length after sign-extension
        :return: A new StridedInterval
770030
def sign_extend(self, new_length):
        

        msb = self.extract(self.bits - 1, self.bits - 1).eval(2)
        if msb == [ 0 ]:
            # All positive numbers
            return self.zero_extend(new_length)
        if msb == [ 1 ]:
            # All negative numbers
            si = self.copy()
            si._bits = new_length
            mask = (2 ** new_length - 1) - (2 ** self.bits - 1)
            si._lower_bound |= mask
            si._upper_bound |= mask

        else:
            # Both positive numbers and negative numbers
            numbers = self._nsplit()
            # Since there are both positive and negative numbers, there must be two bounds after nsplit
            # assert len(numbers) == 2

            all_resulting_intervals = list()

            assert len(numbers) > 0

            for n in numbers:
                a, b = n.lower_bound, n.upper_bound
                mask_a = 0
                mask_b = 0
                mask_n = ((1 << (new_length - n.bits)) - 1) << n.bits

                if StridedInterval._get_msb(a, n.bits) == 1:
                    mask_a = mask_n
                if StridedInterval._get_msb(b, n.bits) == 1:
                    mask_b = mask_n

                si_ = StridedInterval(bits=new_length, stride=n.stride, lower_bound=a | mask_a, upper_bound=b | mask_b)
                all_resulting_intervals.append(si_)
            si = StridedInterval.least_upper_bound(*all_resulting_intervals).normalize()

        si.uninitialized = self.uninitialized
        return si
324698
def new(cls, nsptagname, val):
        
        return OxmlElement(nsptagname, attrs={qn('w:val'): str(val)})
853132
def sign(self, payload):
        
        if self.authenticator:
            return self.authenticator.signed(payload)
        return payload
966220
def _wrapped_signed_div(a, b):
        

        bits = max(a.bits, b.bits)

        # Make sure the divisor is not 0
        divisor_lb = b.lower_bound
        divisor_ub = b.upper_bound
        uninit_flag = a.uninitialized | b.uninitialized

        if divisor_lb == 0:
            # Try to increment it
            if divisor_ub == 0:
                return StridedInterval.empty(bits)
            else:
                divisor_lb = 1
        # If divisor_ub is 0, decrement it to get last but one element
        if divisor_ub == 0:
            divisor_ub = (divisor_ub - 1) & (2 ** bits - 1)

        dividend_positive = StridedInterval._is_msb_zero(a.lower_bound, bits)
        divisor_positive = StridedInterval._is_msb_zero(b.lower_bound, bits)

        # TODO: Can we make a more precise estimate of the stride?
        stride = 1
        if dividend_positive and divisor_positive:
            # They are all positive numbers!
            lb = a.lower_bound // divisor_ub
            ub = a.upper_bound // divisor_lb

        elif dividend_positive and not divisor_positive:
            # + / -
            lb = a.upper_bound // StridedInterval._unsigned_to_signed(divisor_ub, bits)
            ub = a.lower_bound // StridedInterval._unsigned_to_signed(divisor_lb, bits)

        elif not dividend_positive and divisor_positive:
            # - / +
            lb = StridedInterval._unsigned_to_signed(a.lower_bound, bits) // divisor_lb
            ub = StridedInterval._unsigned_to_signed(a.upper_bound, bits) // divisor_ub

        else:
            # - / -
            lb = StridedInterval._unsigned_to_signed(a.upper_bound, bits) // \
                 StridedInterval._unsigned_to_signed(b.lower_bound, bits)
            ub = StridedInterval._unsigned_to_signed(a.lower_bound, bits) // \
                 StridedInterval._unsigned_to_signed(b.upper_bound, bits)

        return StridedInterval(bits=bits, stride=stride, lower_bound=lb, upper_bound=ub, uninitialized=uninit_flag)
522225
protected AstNode unary(boolean required) throws ScanException, ParseException {
		AstNode v = null;
		switch (token.getSymbol()) {
			case NOT:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.NOT);
				break;
			case MINUS:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.NEG);
				break;
			case EMPTY:
				consumeToken();
				v = createAstUnary(unary(true), AstUnary.EMPTY);
				break;
			case EXTENSION:
				if (getExtensionHandler(token).getExtensionPoint() == ExtensionPoint.UNARY) {
					v = getExtensionHandler(consumeToken()).createAstNode(unary(true));
					break;
				}
			default:
				v = value();
		}
		if (v == null && required) {
			fail(EXPR_FIRST);
		}
		return v;
	}
808039
def sign(self, payload, signing_key_or_keys):
        
        if isinstance(signing_key_or_keys, list):
            return self._sign_multi(payload, signing_key_or_keys)

        else:
            return self._sign_single(payload, signing_key_or_keys)
1304682
void signedSubtract(MutableBigInteger addend) {
        if (sign == 1)
            sign = sign * subtract(addend);
        else
            add(addend);
        if (intLen == 0)
             sign = 1;
    }
647087
def get_encoded_seq_len(self, seq_len: int) -> int:
        
        return int(ceil(seq_len / self.pool_stride))
194112
def new(self, length, blocknum):
        # type: (int, int) -> None
        '''
        
        '''
        if self._initialized:
            raise pycdlibexception.PyCdlibInternalError('UDF Long AD already initialized')

        self.extent_length = length
        self.log_block_num = blocknum
        self.part_ref_num = 0  # FIXME: we should let the user set this
        self.impl_use = b'\x00' * 6

        self._initialized = True
170506
def set_length(len , fill_char)
      return if len <= 0
      old = char_length
      return if old >= len
      self.char_length = len
      check_length
      fill_from_with( old + 1 , fill_char )
    end
872003
def _add_length_constrain(token_lst: List[Dict], lengths: List) -> List[Dict]:
        

        result = []
        for a_token in token_lst:
            for length in lengths:
                if type(length) == str and length and length.isdigit():
                    a_token[attrs.LENGTH] = int(length)
                    result.append(copy.deepcopy(a_token))
                elif type(length) == int:
                    a_token[attrs.LENGTH] = int(length)
                    result.append(copy.deepcopy(a_token))
        return result
530742
def btc_tx_der_encode_length(l):
    
    if l < 0:
        raise ValueError("length cannot be negative")

    if l < 0x80:
        return int2byte(l)
    s = ("%x" % l).encode()
    if len(s) % 2:
        s = b("0") + s
    s = binascii.unhexlify(s)
    llen = len(s)
    return int2byte(0x80 | llen) + s
113809
function ensureLength (self, _newLength) {
  var newLength;
  if (_newLength > MAX_LENGTH) {
    newLength = MAX_LENGTH;
  } else {
    newLength = _newLength | 0;
  }
  var proto = Object.getPrototypeOf(self);
  var cur = proto[length] | 0;
  var num = newLength - cur;
  if (num > 0) {
    var desc = {};
    debug('creating a descriptor object with %o entries', num);
    for (var i = cur; i < newLength; i++) {
      desc[i] = setup(i);
    }
    debug('calling `Object.defineProperties()` with %o entries', num);
    Object.defineProperties(proto, desc);
    proto[length] = newLength;
  }
  return newLength;
}
796869
public long expectSigned(int bytes) throws IOException {
        switch (bytes) {
            case 8:
                return expectLong();
            case 4:
                return expectInt();
            case 2:
                return expectShort();
            case 1:
                return expectByte();
        }
        throw new IllegalArgumentException("Unsupported byte count for signed: " + bytes);
    }
972343
function PrependLength(buffer, len) {
  let lenBuf = new Buffer(4);
  lenBuf.writeUInt32LE(len, 0);
  return Buffer.concat([lenBuf, buffer], buffer.length + 4);
}
189126
def footer_length(header):
    
    footer_length = 0
    if header.algorithm.signing_algorithm_info is not None:
        footer_length += 2  # Signature Length
        footer_length += header.algorithm.signature_len  # Signature
    return footer_length
144766
def new(cls, signatures: [Signature]) -> 'MultiSignature':
        
        logger = logging.getLogger(__name__)
        logger.debug("MultiSignature::new: >>>")

        # noinspection PyCallingNonCallable,PyTypeChecker
        signature_c_instances = (c_void_p * len(signatures))()
        for i in range(len(signatures)):
            signature_c_instances[i] = signatures[i].c_instance

        c_instance = c_void_p()
        do_call(cls.new_handler, signature_c_instances, len(signatures), byref(c_instance))

        res = cls(c_instance)

        logger.debug("MultiSignature::new: <<< res: %r", res)
        return res