taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.2-19

Exercise 1.2.2-19

proved in Lean solution written

Rating20
Markersrecommended
KindK2, decide: say whether a claim holds from the written solution
SectionSection 1.2.2 of Volume 1. Companion chapter: Numbers, powers and logarithms

The task

Decide whether every integer of 1414 decimal digits fits into a word of 4747 bits and a sign bit.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Bound the largest 1414-digit number.

Hint 2

Compare it with 2472^{47}, with the help of lg⁡10=1/log⁡102\lg 10 = 1/\log_{10} 2.

Solution

Show the solution

A word of 4747 bits and a sign holds the integers nn with ∣n∣≤247−1|n| \le 2^{47} - 1. An integer with 1414 digits has ∣n∣≤1014−1|n| \le 10^{14} - 1. Now lg⁡1014=14/log⁡102=14/0.30103…=46.5…<47\lg 10^{14} = 14 / \log_{10} 2 = 14 / 0.30103\ldots = 46.5\ldots < 47, so 1014<24710^{14} < 2^{47}, and hence ∣n∣<1014<247|n| < 10^{14} < 2^{47}. Yes, it fits. □\square

Check

247=140 737 488 355 3282^{47} = 140\,737\,488\,355\,328 and 1014=100 000 000 000 00010^{14} = 100\,000\,000\,000\,000. The largest 1414-digit number 99 999 999 999 99999\,999\,999\,999\,999 is below 247−1=140 737 488 355 3272^{47} - 1 = 140\,737\,488\,355\,327. A 1515-digit number may not fit, since 1015>24710^{15} > 2^{47}.

Remarks

The general rule is that dd decimal digits need ⌈dlg⁡10⌉=⌈3.3219 d⌉\lceil d \lg 10 \rceil = \lceil 3.3219\,d \rceil bits for the magnitude.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.