Java examples for java.math:BigInteger
convert BigInteger To Long
//package com.java2s; import java.math.BigInteger; public class Main { public static void main(String[] argv) throws Exception { BigInteger bigInteger = new BigInteger("1234"); System.out.println(convertToLong(bigInteger)); }/*from ww w . j av a 2 s . c o m*/ public static long convertToLong(BigInteger bigInteger) { if (bigInteger.compareTo(BigInteger.valueOf(Long.MAX_VALUE)) == 1) { return Long.MAX_VALUE; } else { return bigInteger.longValue(); } } }