what data type is suitable for a given 20 digit numbers like 12111111111111111111
and could be converted to binary?
I tried long
but it's goes out of range.
what data type is suitable for a given 20 digit numbers like 12111111111111111111
and could be converted to binary?
I tried long
but it's goes out of range.
java.math.BigInteger
is for "Immutable arbitrary-precision integers" - should fit your needs perfectly.
Try this:
BigInteger b1 = new BigInteger("12111111111111111111");
BigInteger b2 = new BigInteger("12111111111111111112");
System.out.println(b1.add(b2));
System.out.println(" binary format of b1 is : " + b1.toString(2));
Well u can use bigInteger that is having large length of the number that what u want.
try this.
java.math.BigInteger bignumber = new BigInteger("1211111111111255511236");
hope that will help.