Here you can find the source of renderBigInteger(final BigInteger bint)
Parameter | Description |
---|---|
bint | the big integer object to render |
public static byte[] renderBigInteger(final BigInteger bint)
//package com.java2s; /*//from w ww . j a v a 2 s.co m * Copyright (c) 2014 Stephan D. Cote' - All rights reserved. * * This program and the accompanying materials are made available under the * terms of the MIT License which accompanies this distribution, and is * available at http://creativecommons.org/licenses/MIT/ * * Contributors: * Stephan D. Cote * - Initial API and implementation */ import java.math.BigInteger; public class Main { /** * Return an 8 byte array from a BigInteger value. * * Only 8 bytes will be supported, enough for a U64 value of over 18 * quintillion. * * @param bint the big integer object to render * * @return an 8 byte array representing the big integer. */ public static byte[] renderBigInteger(final BigInteger bint) { final byte[] retval = new byte[8]; byte[] arry = bint.toByteArray(); if (arry.length > retval.length) System.arraycopy(arry, arry.length - retval.length, retval, 0, retval.length); else if (arry.length < retval.length) System.arraycopy(arry, 0, retval, retval.length - arry.length, arry.length); else System.arraycopy(arry, 0, retval, 0, retval.length); return retval; } }