Post Reply 
(SR-52) Binary-to-Decimal conversion
06-17-2022, 10:38 PM (This post was last modified: 08-20-2022 11:48 AM by pauln.)
Post: #6
RE: (SR-52) Binary-to-Decimal conversion
Another way of looking at this method is to notice that it transforms the value in register 0 from:

\(a_0 + a_1 \cdot 10 + \cdots + a_n \cdot 10^n\)

into

\(a_0 + a_1 \cdot 2 + \cdots + a_n \cdot 2^n\)

To do so, it transforms \(10^k\) into \(2^k\) using the following general identity:

\(a^k - b^k = (a - b)(a^{k-1} + a^{k-2} \cdot b + \cdots + b^{k-1})\)

Applied to a = 10 and b = 2, we get:

\(10^k - 2^k = 8 \cdot (10^{k-1} + 10^{k-2} \cdot 2 + \cdots + 2^{k-1})\)

This explains the 8 at the beginning of the program as well as the values in register 2 (initially 8 and then 16, 32, 64, ...).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (SR-52) Binary-to-Decimal conversion - pauln - 06-17-2022 10:38 PM



User(s) browsing this thread: 1 Guest(s)