Java BigInteger Calculate getAddressText(BigInteger address)

Here you can find the source of getAddressText(BigInteger address)

Description

get Address Text

License

Open Source License

Declaration

public static String getAddressText(BigInteger address) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2010 Wind River Systems, Inc. and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://from ww  w .  j a  v a2  s  . c  o m
 *     Wind River Systems - initial API and implementation
 *     Freescale Semiconductor - refactoring
 *******************************************************************************/

import java.math.BigInteger;

public class Main {
    public static String getAddressText(BigInteger address) {
        if (address == null) {
            return "<null>"; //$NON-NLS-1$
        }
        if (address.compareTo(BigInteger.ZERO) < 0) {
            return address.toString();
        }
        String hex = address.toString(16);
        return "0x" + "0000000000000000".substring(hex.length() + (address.bitLength() <= 32 ? 8 : 0)) + hex; //$NON-NLS-1$ //$NON-NLS-2$
    }
}

Related

  1. GCD(BigInteger x, BigInteger y)
  2. gcd(BigInteger... values)
  3. gcd(Iterable nums)
  4. gcdEuclides(BigInteger a, BigInteger b)
  5. gcdExtended(BigInteger p, BigInteger q)
  6. getByteArrayFromBigIntegerArray(Object value)
  7. getBytes(BigInteger bi, int minLen)
  8. getBytes(BigInteger big, int bitlen)
  9. getBytesWithoutSign(BigInteger arg)