Java tutorial
//package com.java2s; import java.math.BigInteger; public class Main { public static final BigInteger castToBigInteger(Object paramObject) { if (paramObject == null) { return null; } if ((paramObject instanceof BigInteger)) { return (BigInteger) paramObject; } if (((paramObject instanceof Float)) || ((paramObject instanceof Double))) { return BigInteger.valueOf(((Number) paramObject).longValue()); } String str = paramObject.toString(); if (str.length() == 0) { return null; } return new BigInteger(str); } }