Unfortunately, there is no exact solution without high precision calculations. For example, (I will use MATLAB for my work, including the precision tools that I wrote myself), what is 2 ^ 200? In base 10 we get:
vpij(2)^200 ans = 1606938044258990275541962092341162602522202993782792835301376
This number is presented in binary format using 201 base 2 digits. However, for 2 ^ 200-1, only 200 base 2 digits are required.
vpij(2)^200 - 1 ans = 1606938044258990275541962092341162602522202993782792835301375
Now we can calculate the log of these numbers as double, taking only higher-order digits. We need to add 1 to base 2 of the logarithm of a number to find out how many digits of base 2 are needed to represent it.
format long g 1 + log2(vpij(2)^200) ans = 201 1 + log2(vpij(2)^200 - 1) ans = 201
Here log2 did just that, taking the upper decimal digits to compute this log. See that he canβt say that the second number really requires that less bit is stored in binary form.
vpij2bin(vpij(2)^200) ans = 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 vpij2bin(vpij(2)^200 - 1) ans = 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
We can see what happens by taking a high precision journal of these numbers. Thus, with an accuracy of 100 decimal places,
log2(hpf(2,100)^200) ans = 200 log2(hpf(2,100)^200 - 1) ans = 199.9999999999999999999999999999999999999999999999999999999999991022086719253476184905817230522465495
The difference between the two numbers is very small.
log10(hpf(2,100)^200) - log10(hpf(2,100)^200 - 1) ans = 2.702621195974725251000559400026211938865e-61
Thus, any calculation using logs should be interrupted here if the high precision log itself is not accepted. In the best case, you may be in the right number, but nothing more. Therefore, if your goal is to allocate enough space for a number, then always highlight another digit than is necessary. That should be enough until you start working with REALLY huge powers.
(VPIJ is the new integer form of integer variable precision in MATLAB, which will directly replace my old VPI tool. HPF is already available in file sharing.)