[Solved] How to calculate any power of a base 2 number in Java by not using BigInteger?


I’m not sure I understand your problem completely, but if n is the binary number converted to a decimal number, then you are playing with way too large numbers.

Consider the binary number as decimal. Your example would be the decimal number 4294969345. Just try to consider what 2^4294969345 would be. As an example 2^429 would be 1.38633485×10^129. There’s no way you can execute this.

I agree with the others, please share your code, and maybe you can get a better answer.

EDIT: If it’s just a conversion from the big binary number to a decimalnumber, you can use Long.parseLong(binaryNumber, 2), where binaryNumber is your binary number as a String.

1

solved How to calculate any power of a base 2 number in Java by not using BigInteger?