View Single Post
Old 2020-01-24, 13:47   #15
Dr Sardonicus
 
Dr Sardonicus's Avatar
 
Feb 2017
Nowhere

63028 Posts
Default

Quote:
Originally Posted by Happy5214 View Post
"floor" (for positive numbers) just means to truncate the part after the decimal point. It really should be the ceiling (think of 100, which has 3 digits and a base-10 log of 2).

The multiplication by (log(2) / log(10)) converts the exponent (which is the base-2 log of the 2^n part) to the base-10 log. The first 2 (I think) was supposed to be the k value (10), which really should have been 1. Replace that with the base-10 log of whatever k is (e.g. log(231) / log(10) for your last example). The -1 at the end can basically be ignored.
Actually, I meant 2. Generally, the number of decimal digits in N is 1 + floor(log(N)/log(10)). If N = 10*2^13509 - 1, then (since N+1 is not a power of ten), N has the same number of decimal digits as N+1, so we may use 1 + floor(log(N+1)/log(10)). Now

log(N+1) = log(10) + 13509*log(2), so we have

1 + floor(log(N+1)/log(10)) = 2 + floor(13509*log(2)/log(10)), which is 4068.

Siccing the mighty Pari-GP on the previous query,

Code:
? 1+floor((log(231) + 233528*log(2))/log(10))

%2 = 70302
As a ballpark estimate, log(2)/log(10) is close to 0.3 (more closely, 0.30102999).

Also, I meant floor(), the integer floor. The integer ceiling of an exact integer is that integer, so it gives the wrong answer for exact powers of ten; ceil(log(100)/log(10)) is 2, not 3.
Dr Sardonicus is offline   Reply With Quote