I am trying to convert a BigInteger or a String variable containing no.s into a BigInteger Array. How can i do this. please reply. for eg.
BigInteger = 278490638904984
BigInteger Array = [2,7,8,4,9,0,6,3,8,9,0,4,9,8,4]
public static void main(String[] args) {
String s = "278490638904984";
BigInteger[] big = new BigInteger[s.length()];
for (int i = 0; i < s.length(); i++) {
big[i] = new BigInteger(String.valueOf(s.charAt(i)));
}
System.out.println(Arrays.toString(big));
}
Output:
[2, 7, 8, 4, 9, 0, 6, 3, 8, 9, 0, 4, 9, 8, 4]
For which purpose? It's a little bit strange...
BigInteger bi = new BigInteger( "278490638904984" );
String s = bi.toString();
int len = s.length();
BigInteger[] digits = new BigInteger[len];
for( int i = 0; i < len; ++i ) {
digits[i] = BigInteger.valueOf( s.charAt(i)-'0' );
}