Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #28 May 10 2020 23:02:48
%S 0,1,3,2,6,22,36,28,156,412,24,1048,3096,1808,6384,22768,34464,31072,
%T 162144,424288,48576,1097152,3194304,1611392,6777216,23554432,
%U 32891136,34217728,168435456,436870912,73741824,1147483648,3294967296,1410065408,7179869184,24359738368
%N Distance of closest integer power of 10 to the n-th power of 2.
%C a(n) is a measure for how well powers of 2 may be approximated by powers of 10. It is e.g. relevant to unit conventions for the magnitude of data (e.g. 1 megabyte is approximately 1 mebibyte). The closely related sequence of distances of the closest integer power of 2 to the n-th power of 10 gives a measure for the precision of floating point expressions in computing applications.
%H Alois P. Heinz, <a href="/A334588/b334588.txt">Table of n, a(n) for n = 0..3322</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Floating-point_arithmetic">Floating-point arithmetic</a>
%H Wikipedia, <a href="https://en.wikipedia.org/wiki/Mebibyte">Mebibyte</a>
%e For n=2, a(2) = |4-1| = 3.
%e For n=10, a(10) = min(|2^10-10^3|,|2^10-10^4|) = |1024-1000| = 24.
%p a:= n-> (m-> (p-> min(m-10^p, 10^(p+1)-m))(ilog10(m)))(2^n):
%p seq(a(n), n=0..37); # _Alois P. Heinz_, May 07 2020
%t A[n_] := Min[Abs[(2^n) - 10^Length[IntegerDigits[2^n]]],
%t Abs[(2^n) - 10^(Length[IntegerDigits[2^n]] - 1)]]
%o (PARI) a(n) = my(i=logint(2^n, 10)); min(abs(10^i-2^n), abs(10*10^i-2^n)); \\ _Jinyuan Wang_, May 06 2020
%Y Cf. A000079 (2^n), A011557 (10^n).
%K nonn
%O 0,3
%A _Timon S. Gutleb_, May 06 2020
%E More terms from _Jinyuan Wang_, May 06 2020