Here you can find the source of byte_size(BigInteger bi)
Parameter | Description |
---|---|
bi | a parameter |
public static int byte_size(BigInteger bi)
//package com.java2s; // modify it under the terms of the GNU General Public License as import java.math.BigInteger; public class Main { /**//ww w . j a v a 2s.com * BigInteger size in bytes. For {@link java.math.BigInteger#ZERO * BigInteger.ZERO} it returns 1. * Note that the value computed here might be different * from * {@link java.math.BigInteger#toByteArray BigInteger.toByteArray}.length * because the latter might add a leading zero byte. * * @param bi * @return the size in bytes of {@code bi} */ public static int byte_size(BigInteger bi) { int l = (bi.bitLength() + 7) / 8; return l == 0 ? 1 : l; } }