Hi, I am adding two BigInteger each for a binary number in this manner-
//x and y are StringBuilder object having large binary number on each
BigInteger a = new BigInteger(x.toString(), 2);
BigInteger b = new BigInteger(y.toString(), 2);
BigInteger c = a.add(b);
Now i need to know the bit value of given index in BigInteger c. For that, I am converting c to binary string using
c.toString(2); then i am using
string.charAt(index); method. This looks pretty fine but the last BigInteger to binary conversion has not that much use because i just need to know the bit, not the whole binary number. This can improve the program. Is there any better way for achieving the same?
Thank you