Here you can find the source of getUnsignedBigInteger(long x)
Parameter | Description |
---|---|
x | a parameter |
public static final BigInteger getUnsignedBigInteger(long x)
//package com.java2s; import java.math.BigInteger; public class Main { /**/* w w w .ja v a2s .c o m*/ * 2^64 */ final static BigInteger x64 = BigInteger.ONE.shiftLeft(64); /** * Ensure that the passed long parameter will be interpreted as a positive value. * @param x */ public static final BigInteger getUnsignedBigInteger(long x) { BigInteger z = BigInteger.valueOf(x); if (z.signum() < 0) return z.add(x64); else return z; } /** * Ensure that the passed long parameter will be interpreted as a positive value. * * @param x - value. * @param bitWidth - VM word size. * @return a positive value. */ public static final BigInteger getUnsignedBigInteger(long x, int bitWidth) { return BigInteger.valueOf(x & (((long) 1 << bitWidth) - 1)); } }