Thursday, October 15, 2026

[bedtmcgm] decimal expansions of negative powers of 2

the digits in the decimal expansion of negative powers of 2, equivalently positive powers of 0.5, are the same as the digits of positive powers of 5.  positive powers of 5 can be computed with arbitrary precision integer arithmetic only: arbitrary precision floating point not necessary.  then, the only difficulty is determining the number of zeros in front after the decimal point.  in the perl script below, the number of zeros is computed and stored in $c.  "x" is the perl string repetition operator.  the general idea is the total length after the decimal point grows by 1 each time, yielding a pretty triangle.

perl -lwe 'use bigint; $b=1; for($i=1;;++$i){ $b*=5; $c=$i-length$b; $_= "0." . ("0"x$c) . $b; print"$_ $i"}'

0.5 1
0.25 2
0.125 3
0.0625 4
0.03125 5
0.015625 6
0.0078125 7
0.00390625 8
0.001953125 9
0.0009765625 10
0.00048828125 11
0.000244140625 12
0.0001220703125 13
0.00006103515625 14
0.000030517578125 15
0.0000152587890625 16
0.00000762939453125 17
0.000003814697265625 18
0.0000019073486328125 19
0.00000095367431640625 20

if scientific notation is acceptable, then one can cheat:

5e-1
25e-2
125e-3
625e-4
3125e-5
15625e-6

where the negative exponent decreases by 1 each time.  this works because 5^n * 10^-n = (1/2)^n .

No comments :