Returns the field *value* of the `Decimal` field as a signed integer.
548055
def as_signed(self):
        
        return self._cast(self._value, self._min(True), self._max(True), True)
1282064
def get_signed_area(self):
        
        accum = 0.0
        for i in range(len(self.verts)):
            j = (i + 1) % len(self.verts)
            accum += (
                self.verts[j][0] * self.verts[i][1] -
                self.verts[i][0] * self.verts[j][1])
        return accum / 2
1072813
def format_field(self, field):
        
        if field is None:
            return "NULL"
        elif isinstance(field, TypeError):
            return "TypeError"
        elif isinstance(field, Decimal):
            if field % 1 == 0:
                return str(int(field))
            return str(float(field))
        elif isinstance(field, set):
            return "(" + ", ".join([self.format_field(v) for v in field]) + ")"
        elif isinstance(field, datetime):
            return field.isoformat()
        elif isinstance(field, timedelta):
            rd = relativedelta(
                seconds=int(field.total_seconds()), microseconds=field.microseconds
            )
            return delta_to_str(rd)
        elif isinstance(field, Binary):
            return "<Binary %d>" % len(field.value)
        pretty = repr(field)
        if pretty.startswith("u'"):
            return pretty[1:]
        return pretty
950004
def value_to_int(attrib, key):
    
    val = attrib.get(key, 0)
    if isinstance(val, str):
        if val.isspace() or val == '':
            return 0
    return val
794751
def get_pk(self, field_val):
        """"""
        field_name = self.schema.pk.name
        return self.is_field(field_name, field_val).get_one()
438437
protected int getIntValue() {
		if (label.equals(AbcTokens.DIGIT)
				|| label.equals(AbcTokens.DIGITS)) {
			try {
				return Integer.parseInt(value);
			} catch (NumberFormatException nfe) {
				return -1;
			}
		}
		else
			return -1;
	}
911173
def signed_int_to_unsigned_hex(signed_int: int) -> str:
    
    hex_string = hex(struct.unpack('Q', struct.pack('q', signed_int))[0])[2:]
    if hex_string.endswith('L'):
        return hex_string[:-1]
    return hex_string
626257
private Object getValue(FieldType field, byte[] block)
   {
      Object result = null;

      switch (block[0])
      {
         case 0x07: // Field
         {
            result = getFieldType(block);
            break;
         }

         case 0x01: // Constant value
         {
            result = getConstantValue(field, block);
            break;
         }

         case 0x00: // Prompt
         {
            result = getPromptValue(field, block);
            break;
         }
      }

      return result;
   }
1018773
def format_decimal_field(__, prec, number, locale):
    
    prec = 0 if prec is None else int(prec)
    if number < 0:
        prec += 1
    return format(number, u'0%dd' % prec)
502925
def _decimal_to_128(value):
    
    with decimal.localcontext(_DEC128_CTX) as ctx:
        value = ctx.create_decimal(value)

    if value.is_infinite():
        return _NINF if value.is_signed() else _PINF

    sign, digits, exponent = value.as_tuple()

    if value.is_nan():
        if digits:
            raise ValueError("NaN with debug payload is not supported")
        if value.is_snan():
            return _NSNAN if value.is_signed() else _PSNAN
        return _NNAN if value.is_signed() else _PNAN

    significand = int("".join([str(digit) for digit in digits]))
    bit_length = _bit_length(significand)

    high = 0
    low = 0
    for i in range(min(64, bit_length)):
        if significand & (1 << i):
            low |= 1 << i

    for i in range(64, bit_length):
        if significand & (1 << i):
            high |= 1 << (i - 64)

    biased_exponent = exponent + _EXPONENT_BIAS

    if high >> 49 == 1:
        high = high & 0x7fffffffffff
        high |= _EXPONENT_MASK
        high |= (biased_exponent & 0x3fff) << 47
    else:
        high |= biased_exponent << 49

    if sign:
        high |= _SIGN

    return high, low
1248873
def positive_integer(anon, obj, field, val):
    
    return anon.faker.positive_integer(field=field)
898581
def integer(token):
        
        token = token.strip()
        neg = False
        if token.startswith(compat.b('-')):
            token = token[1:]
            neg = True
        if token.startswith(compat.b('0x')):
            result = int(token, 16)     # hexadecimal
        elif token.startswith(compat.b('0b')):
            result = int(token[2:], 2)  # binary
        elif token.startswith(compat.b('0o')):
            result = int(token, 8)      # octal
        else:
            try:
                result = int(token)     # decimal
            except ValueError:
                result = int(token, 16) # hexadecimal (no "0x" prefix)
        if neg:
            result = -result
        return result
1144806
def decimal(self, var, default=NOTSET, force=True):
        
        return self._get(var, default=default, cast=Decimal, force=force)
832638
def get_int_id(self, str_id):
        """"""
        if not str_id in self.mapping:
            if self.curr_id == IdRemapper.INT_MAX:
                return None # No more 32 bits signed integers available
            self.mapping[str_id] = self.curr_id
            self.r_mapping[self.curr_id] = str_id
            self.curr_id += 1
        return self.mapping[str_id]
745481
def decimal128_to_decimal(b):
    ""
    v = decimal128_to_sign_digits_exponent(b)
    if isinstance(v, Decimal):
        return v
    sign, digits, exponent = v
    return Decimal((sign, Decimal(digits).as_tuple()[1], exponent))
815920
def _parse_signed_int_components(buf):
    
    sign_bit = 0
    value = 0

    first = True
    while True:
        ch = buf.read(1)
        if ch == b'':
            break
        octet = ord(ch)
        if first:
            if octet & _SIGNED_INT_SIGN_MASK:
                sign_bit = 1
            value = octet & _SIGNED_INT_SIGN_VALUE_MASK
            first = False
        else:
            value <<= 8
            value |= octet

    return sign_bit, value
733466
def get_field(field, slog, fl=False):
        
        field += r'\:\s+([\d\.]+)'
        match = re.search(field, slog)
        if match:
            if fl:
                return float(match.group(1))
            return int(match.group(1))
        return 0