Convert this MutableBigInteger to a long value. The caller has to make
sure this MutableBigInteger can be fit into long.
978519
private long toLong() {
        assert (intLen <= 2) : "this MutableBigInteger exceeds the range of long";
        if (intLen == 0)
            return 0;
        long d = value[offset] & LONG_MASK;
        return (intLen == 2) ? d << 32 | (value[offset + 1] & LONG_MASK) : d;
    }
1095911
static long toLong(final byte[] buffer, final int offset) {
        final long value1 = toInt(buffer, offset);
        final long value2 = toInt(buffer, offset + 4);
        return (value1 << 32) + ((value2 << 32) >>> 32);
    }
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);
        }
    }
1022553
public static long getLong(String key, long valueIfNullOrNotParseable) {
        String value = System.getProperty(key);
        if (Strings.isNullOrEmpty(value)) {
            return valueIfNullOrNotParseable;
        }
        try {
            return Long.parseLong(value);
        } catch (NumberFormatException e) {
            return valueIfNullOrNotParseable;
        }
    }
356222
@NonNull
    public Parameters setLong(@NonNull String name, long value) {
        return setValue(name, value);
    }
162993
public Long getParaToLong(String name, Long defaultValue) {
		return toLong(request.getParameter(name), defaultValue);
	}
25770
public static Long getAsLong(Object value) {
		Long result = null;

		try {
			if (value instanceof String) {
				result = Long.valueOf((String) value);
			} else if (value instanceof Number) {
				result = ((Number) value).longValue();
			} else {
				result = null;
			}
		} catch (Exception e) {
			result = null;
		}

		return result == null ? 0 : result;
	}
426324
@NonNull
    @Override
    public MutableDictionary setLong(@NonNull String key, long value) {
        return setValue(key, value);
    }
530898
public long getLong(String key, long defaultValue) {
    if (containsKey(key)) {
      return Long.parseLong(get(key));
    } else {
      return defaultValue;
    }
  }
176121
public static long getLong(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).longValue();
    }
257377
public long getValueAsLong(int index) throws IOException {
        if (index >= structure.valueSizes.size()) {
            throw new IOException("Index " + index + " is out of range.");
        }
        return Bytes.toLong(value, structure.valueByteOffsets.get(index));
    }
476555
public Long decrBy(Object key, long longValue) {
		Jedis jedis = getJedis();
		try {
			return jedis.decrBy(keyToBytes(key), longValue);
		}
		finally {close(jedis);}
	}
637581
@NonNull
    @Override
    public MutableDocument setLong(@NonNull String key, long value) {
        return setValue(key, value);
    }
312472
@Override
    public long getLong(@NonNull String key) {
        if (key == null) { throw new IllegalArgumentException("key cannot be null."); }

        synchronized (lock) {
            return CBLConverter.asLong(getMValue(internalDict, key), internalDict);
        }
    }
511116
public BigInteger asBigInteger() throws IOException {
        if (_value instanceof BigInteger) {
            return (BigInteger) _value;
        }
        if (_value instanceof BigDecimal) {
            BigDecimal dec = (BigDecimal) _value;
            return dec.toBigInteger();
        }
        return BigInteger.valueOf(_value.longValue());
    }
329701
public long longValue() {
		long value;
		value = Long.parseLong(this.param);
		if(this.isNeg) value = (-value);
		return value;
	}
1030556
public static Long toLong(Object o, Long defaultValue) {
	if (o instanceof Long) return (Long) o;
	if (defaultValue != null) return Long.valueOf(toLongValue(o, defaultValue.longValue()));

	long res = toLongValue(o, Long.MIN_VALUE);
	if (res == Long.MIN_VALUE) return defaultValue;
	return Long.valueOf(res);
    }