(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
 pauln Member Posts: 84 Joined: May 2022
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, ...).
 « Next Oldest | Next Newest »

 Messages In This Thread (SR-52) Binary-to-Decimal conversion - SlideRule - 01-17-2020, 04:49 PM RE: (SR-52) Binary-to-Decimal conversion - Thomas Klemm - 06-16-2022, 06:54 AM RE: (SR-52) Binary-to-Decimal conversion - pauln - 06-17-2022, 12:47 AM RE: (SR-52) Binary-to-Decimal conversion - Thomas Klemm - 06-17-2022, 06:48 AM RE: (SR-52) Binary-to-Decimal conversion - Thomas Klemm - 06-17-2022, 07:37 AM RE: (SR-52) Binary-to-Decimal conversion - pauln - 06-17-2022 10:38 PM RE: (SR-52) Binary-to-Decimal conversion - Thomas Klemm - 06-18-2022, 05:23 AM RE: (SR-52) Binary-to-Decimal conversion - pauln - 06-18-2022, 05:36 AM

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