Java BigInteger Calculate numberToIpv4(BigInteger ipNumber)

Here you can find the source of numberToIpv4(BigInteger ipNumber)

Description

number To Ipv

License

Open Source License

Declaration

public static String numberToIpv4(BigInteger ipNumber) 

Method Source Code

//package com.java2s;
/*//from  ww  w. j a  v  a 2s. com
 * Copyright (C) 2010 Viettel Telecom. All rights reserved.
 * VIETTEL PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

import java.math.BigInteger;

public class Main {
    public static String numberToIpv4(BigInteger ipNumber) {

        String ipString = "";
        BigInteger a = new BigInteger("FF", 16);

        for (int i = 0; i < 4; i++) {
            ipString = ipNumber.and(a).toString() + "." + ipString;

            ipNumber = ipNumber.shiftRight(8);
        }

        return ipString.substring(0, ipString.length() - 1);
    }
}

Related

  1. modulus(BigInteger value, BigInteger divider, int modulo, int... weight)
  2. multi_exponent(BigInteger[] base, BigInteger[] exponent, BigInteger modulus)
  3. multiply(BigInteger x, BigInteger y)
  4. negative(BigInteger n)
  5. normalizarParaBigInteger(Number numero, RoundingMode modo)
  6. numberToShortString(BigInteger number)
  7. order(BigInteger a, BigInteger p, BigInteger f[], BigInteger e[])
  8. parseBigInteger(String s, BigInteger defaultValue)
  9. parseBinaryBigInteger(final byte[] buffer, final int offset, final int length, final boolean negative)