Converter from a numeric object to Long. Input is checked to be
within range represented by Long.
352374
static Long convertToLong(SessionInterface session, Object a) {

        if (a instanceof Integer) {
            return ValuePool.getLong(((Integer) a).intValue());
        } else if (a instanceof Long) {
            return (Long) a;
        } else if (a instanceof BigDecimal) {
            BigDecimal bd = (BigDecimal) a;

            if (bd.compareTo(MAX_LONG) > 0 || bd.compareTo(MIN_LONG) < 0) {
                throw Error.error(ErrorCode.X_22003);
            }

            return ValuePool.getLong(bd.longValue());
        } else if (a instanceof Double || a instanceof Float) {
            double d = ((Number) a).doubleValue();

            if (session instanceof Session) {
                if (!((Session) session).database.sqlConvertTruncate) {
                    d = java.lang.Math.rint(d);
                }
            }

            if (Double.isInfinite(d) || Double.isNaN(d)
                    || d >= (double) Long.MAX_VALUE + 1
                    || d <= (double) Long.MIN_VALUE - 1) {
                throw Error.error(ErrorCode.X_22003);
            }

            return ValuePool.getLong((long) d);
        } else {
            throw Error.error(ErrorCode.X_42561);
        }
    }
20402
def long_encode(input, errors='strict'):
    
    if not isinstance(input, text_type):
        input = text_type(input, sys.getdefaultencoding(), errors)
    length = len(input)
    input = unicodedata.normalize('NFKC', input)
    return input.translate(long_table), length
946059
public static long getLong(JsonObject object, String field, long defaultValue) {
        final JsonValue value = object.get(field);
        if (value == null || value.isNull()) {
            return defaultValue;
        } else {
            return value.asLong();
        }
    }
1185496
def _normalize(value):
        
        if hasattr(value, 'value'):
            value = value.value
        if value is not None:
            value = long(value)
        return value
138572
def _send_long(self,value):
        

        # Coerce to int. This will throw a ValueError if the value can't 
        # actually be converted.
        if type(value) != int:
            new_value = int(value)
            
            if self.give_warnings:
                w = "Coercing {} into int ({})".format(value,new_value)
                warnings.warn(w,Warning)
                value = new_value

        # Range check
        if value > self.board.long_max or value < self.board.long_min:
            err = "Value {} exceeds the size of the board's long.".format(value)
            raise OverflowError(err)
           
        return struct.pack(self.board.long_type,value)
1096132
def field_to_long(value):
        
        if isinstance(value, (int, long)):
            return long(value)
        elif isinstance(value, basestring):
            return bytes_to_long(from_hex(value))
        else:
            return None
1178613
def __convertLongToString(self, iValue):
        
        string = ''
        strValue = str(hex(iValue))

        string = strValue.lstrip('0x')
        string = string.rstrip('L')

        return string
265783
public static int safeLongToInt(long l) {
        if (l > (long)Integer.MAX_VALUE || l < (long) Integer.MIN_VALUE) {
            throw new IllegalStateException("Cannot convert long to int: " + l);
        }
        return (int)l;
    }
872680
public static Number transformNumber( Number input ) {
      if( input instanceof Float ){
         return new Double( input.toString() );
      }else if( input instanceof Short ){
         return new Integer( input.intValue() );
      }else if( input instanceof Byte ){
         return new Integer( input.intValue() );
      }else if( input instanceof Long ){
         Long max = new Long( Integer.MAX_VALUE );
         if( input.longValue() <= max.longValue() && input.longValue() >= Integer.MIN_VALUE ){
            return new Integer( input.intValue() );
         }
      }

      return input;
   }
641072
public Long getAsLong(String key) {
        Object value = mValues.get(key);
        try {
            return value != null ? ((Number) value).longValue() : null;
        } catch (ClassCastException e) {
            if (value instanceof CharSequence) {
                try {
                    return Long.valueOf(value.toString());
                } catch (NumberFormatException e2) {
                    DLog.e(TAG, "Cannot parse Long value for " + value + " at key " + key);
                    return null;
                }
            } else {
                DLog.e(TAG, "Cannot cast value for " + key + " to a Long: " + value, e);
                return null;
            }
        }
    }
303328
def wr_long(f, x):
    """"""
    if PYTHON3:
        f.write(bytes([x        & 0xff]))
        f.write(bytes([(x >> 8)  & 0xff]))
        f.write(bytes([(x >> 16) & 0xff]))
        f.write(bytes([(x >> 24) & 0xff]))
    else:
        f.write(chr( x        & 0xff))
        f.write(chr((x >> 8)  & 0xff))
        f.write(chr((x >> 16) & 0xff))
        f.write(chr((x >> 24) & 0xff))
541444
def getLong(t):
    
    i = c_long()
    if PL_get_long(t, byref(i)):
        return i.value
    else:
        raise InvalidTypeError("long")
976011
def read_long(fo, writer_schema=None, reader_schema=None):
    """"""
    c = fo.read(1)

    # We do EOF checking only here, since most reader start here
    if not c:
        raise StopIteration

    b = ord(c)
    n = b & 0x7F
    shift = 7

    while (b & 0x80) != 0:
        b = ord(fo.read(1))
        n |= (b & 0x7F) << shift
        shift += 7

    return (n >> 1) ^ -(n & 1)
84452
public long getLong(String key, long def) {
        Object tmp = objectMap.get(key);
        return tmp != null && tmp instanceof Number ? ((Number) tmp)
                .longValue() : def;
    }
1046996
private long convertToLong(byte[] bin){
        ByteBuffer bb = ByteBuffer.wrap(bin);
        bb.order(ByteOrder.BIG_ENDIAN);
        return bb.getInt();
    }
193690
@Override
    public Long convert(Object value) {
        if (value instanceof Number) {
            double d = ((Number)value).doubleValue();
            if (Double.isNaN(d) || Math.round(d)!=d) throw new IllegalArgumentException("Not a valid long: " + value);
            return ((Number)value).longValue();
        } else if (value instanceof String) {
            return Long.parseLong((String)value);
        } else if (value instanceof Idfiable) {
            return ((Idfiable)value).longId();
        } else return null;
    }
342048
public static long toLongValue(Object o, long defaultValue) {
	if (o instanceof Character) return (((Character) o).charValue());
	else if (o instanceof Boolean) return ((((Boolean) o).booleanValue()) ? 1L : 0L);
	else if (o instanceof Number) return (((Number) o).longValue());
	else if (o instanceof CharSequence) return (long) toDoubleValue(o.toString(), defaultValue);
	else if (o instanceof Castable) {
	    return (long) ((Castable) o).castToDoubleValue(defaultValue);
	}
	else if (o instanceof Character) return (long) (((Character) o).charValue());
	else if (o instanceof ObjectWrap) return toLongValue(((ObjectWrap) o).getEmbededObject(toLong(defaultValue)), defaultValue);

	return defaultValue;
    }