Java BigInteger to toInt(int length, BigInteger bi)

Here you can find the source of toInt(int length, BigInteger bi)

Description

to Int

License

Open Source License

Declaration

public static int[] toInt(int length, BigInteger bi) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.math.BigInteger;

public class Main {
    public static int[] toInt(int length, BigInteger bi) {
        byte[] ba = bi.toByteArray();
        int[] ia = new int[length];
        for (int j = ba.length - 1; j >= 0; j--) {
            int changeByte = ((ba.length - 1 - j) % 4);
            int jj = length - 1 - (ba.length - 1 - j) / 4;
            ia[jj] |= (ba[j] & 0xff) << (changeByte * 8);
        }//ww  w. ja  v  a  2s  .  com
        return ia;
    }
}

Related

  1. toBytesUnsigned(final BigInteger bigInt)
  2. toDecimal(BigInteger value, byte[] buffer, int offset, int length, int itemLength, byte pos)
  3. toEvenLengthHex(BigInteger value)
  4. toFixedLenByteArray(BigInteger x, int resultByteLen)
  5. toInt(BigInteger number)
  6. toIntArray(BigInteger[] input)
  7. toInteger(BigInteger bi)
  8. toInteger(BigInteger integer)
  9. toIntegerBytes(final BigInteger bigInt)