Java BigInteger Parse getBigInteger(Number value)

Here you can find the source of getBigInteger(Number value)

Description

Utility method used to convert a Number into a BigInteger.

License

Open Source License

Parameter

Parameter Description
value Number instance

Return

BigInteger instance

Declaration

public static final BigInteger getBigInteger(Number value) 

Method Source Code


//package com.java2s;
/*//from  ww w  .jav a2  s. c  o  m
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation; either version 2.1 of the License, or (at your
 * option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
 */

import java.math.BigInteger;

public class Main {
    /**
     * Utility method used to convert a Number into a BigInteger.
     *
     * @param value Number instance
     * @return BigInteger instance
     */
    public static final BigInteger getBigInteger(Number value) {
        BigInteger result = null;
        if (value != null) {
            if (value instanceof BigInteger) {
                result = (BigInteger) value;
            } else {
                result = BigInteger.valueOf(Math.round(value.doubleValue()));
            }
        }
        return (result);
    }
}

Related

  1. getBigInteger(byte[] payload, int offset, int length)
  2. getBigInteger(Console console, Function validator)
  3. getBigInteger(Number number)
  4. getBigInteger(String value)
  5. getBigIntegerArrayFromByteArray(byte[] buf)
  6. getBigIntegerValue(final Integer value)
  7. getBinaryNumberInString(BigInteger integerNumber)