Returns a {@code UnsignedLong} representing the same value as the specified
{@code BigInteger}. This is the inverse operation of {@link #bigIntegerValue()}.

@throws IllegalArgumentException if {@code value} is negative or {@code value >= 2^64}
198932
public static UnsignedLong valueOf(BigInteger value) {
    checkNotNull(value);
    checkArgument(value.signum() >= 0 && value.bitLength() <= Long.SIZE,
        "value (%s) is outside the range for an unsigned long value", value);
    return fromLongBits(value.longValue());
  }
1208949
public static int longToInt(long inLong) {

        if (inLong < Integer.MIN_VALUE) {
            return Integer.MIN_VALUE;
        }

        if (inLong > Integer.MAX_VALUE) {
            return Integer.MAX_VALUE;
        }

        return (int) inLong;
    }
634688
public static Double asDouble(Object value) {
    double doubleValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        doubleValue = ((BigDecimal) value).doubleValue();
        break;
      case "java.lang.Integer":
        doubleValue = ((Integer) value).doubleValue();
        break;
      default:
        doubleValue = (Double) value;
        break;
    }
    return doubleValue;
  }
16690
public static long factoriall(int n) {
        checkNonNegative("n", n);
        return (n < long_factorials.length) ? long_factorials[n] : Long.MAX_VALUE;
    }
1104208
public static byte[] vleEncodeLong(final long value) {
    if (Byte.MIN_VALUE <= value && value <= Byte.MAX_VALUE) {
      return new byte[] { (byte) value };
    } else if (Short.MIN_VALUE <= value && value <= Short.MAX_VALUE) {
      return Bytes.fromShort((short) value);
    } else if (Integer.MIN_VALUE <= value && value <= Integer.MAX_VALUE) {
      return Bytes.fromInt((int) value);
    } else {
      return Bytes.fromLong(value);
    }
  }
831440
public static byte[] getFiveBytes(long value) {
        if (value < 0) {
            throw new IllegalArgumentException("negative value not allowed: " + value);
        } else if (value > 1099511627775L) {
            throw new IllegalArgumentException("value out of range: " + value);
        }
        return new byte[]{(byte) (value >> 32), (byte) (value >> 24), (byte) (value >> 16), (byte) (value >> 8),
                (byte) value};
    }
991025
public static BigDecimal inverse(final BigDecimal value) {
        if (isNotZero(value)) {
            return BigDecimal.ONE.setScale(MAX_SCALE_FOR_INVERSE).divide(value, BigDecimal.ROUND_HALF_UP);
        }
        return null;
    }
1259090
def _send_unsigned_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.unsigned_long_max or value < self.board.unsigned_long_min:
            err = "Value {} exceeds the size of the board's unsigned long.".format(value)
            raise OverflowError(err)
          
        return struct.pack(self.board.unsigned_long_type,value)
757147
public long toLong() {
    long value = 0;
    for (final byte b : shiftRight(this.bytes, this.bytes.length * 8
      - this.bitLength)) {
      final long shifted = value << 8;
      value = shifted;
      final int asInt = b & 0xFF;
      value += asInt;
    }
    return value;
  }
500486
public static int calculateEncodedLength(BigInteger value) {
        if (value == null) {
            return 1;
        }
        int bytesLength = (value.bitLength() >> 3) + 1;
        return bytesLength < 0x7f ? (1 + bytesLength) : (5 + bytesLength);
    }
1181013
@Deprecated
public static byte[] convertLongToVarInt(long value) {
	
	// to make it threadsafe - could be optimized at a later stage
	ByteBuffer longBB = ByteBuffer.allocate(EthereumUtil.LONG_SIZE);
	
	longBB.putLong(value);
	byte[] result = longBB.array();
	int leadingZeros=0;
	for (int i=0;i<result.length;i++) {
		if (result[i]==0) {
			leadingZeros++;
		} else {
			break;
		}
	}
	 return Arrays.copyOfRange(result, leadingZeros, result.length);
}
1131992
private static String unsignedToString(int value) {
        if (value >= 0) {
            return Integer.toString(value);
        } else {
            return Long.toString((value) & 0x00000000FFFFFFFFL);
        }
    }
510371
public Bits writeBoundedLong(final long value, final long max)
    throws IOException {
    final int bits = 0 >= max ? 0 : (int) (Math
      .floor(Math.log(max) / Math.log(2)) + 1);
    if (0 < bits) {
      Bits toWrite = new Bits(value, bits);
      this.write(toWrite);
      return toWrite;
    }
    else {
      return Bits.NULL;
    }
  }
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;
    }
872391
public final BigInteger getUlong64() {
        final long long64 = getLong64();

        return (long64 >= 0) ? BigInteger.valueOf(long64) : BIGINT_MAX_VALUE.add(BigInteger.valueOf(1 + long64));
    }
826238
public BigInteger toBigInteger(Object val) {
    if (val == null) {
      return BigInteger.ZERO;
    }
    else if (val instanceof BigInteger) {
      return (BigInteger) val;
    }
    else if (val instanceof Double) {
      if (!Double.isNaN(((Double) val).doubleValue())) {
        return new BigInteger(val.toString());
      }
      else {
        return BigInteger.ZERO;
      }
    }
    else if (val instanceof Number) {
      return new BigInteger(val.toString());
    }
    else if (val instanceof String) {
      String string = (String) val;
      if ("".equals(string.trim())) {
        return BigInteger.ZERO;
      }
      else {
        return new BigInteger(string);
      }
    }
    else if (val instanceof Character) {
      int i = ((Character) val).charValue();
      return BigInteger.valueOf(i);
    }

    throw new ArithmeticException("BigInteger coercion: " + val.getClass().getName() + ":(" + val + ")");
  }
783712
public static BigInteger read(String value) {
		if (!StringUtils.hasText(value)) return null;
		
		return new BigInteger(value);
	}