The MASM Forum

General => The Campus => Topic started by: Mikl__ on May 22, 2015, 01:21:15 PM

Title: The conversion of a binary number of to decimal
Post by: Mikl__ on May 22, 2015, 01:21:15 PM
10-2=8
multiply the number to 8 in the k-step, k-leading digits and subtract the result from (k+1)-leading digits. If the binary number contains k digit, then the process will be completed by k-1 steps
100011012 -> 14110

1.0001101
- 8                  (1*8=8)
-------------
   2.001101
- 16               (2*8=16)
   ------------
    4.01101
  - 32              (4*8=32)
      ----------
       8.1101
     - 64           (8*8=64)
       ---------
       17.101
      -136         (17*8=136)
       ---------
        35.01
      - 280        (35*8=280)
          -------
           70.1
         - 560    (70*8=560)
            ------
            141
Title: Re: The conversion of a binary number of to decimal
Post by: dedndave on May 22, 2015, 01:37:03 PM
that makes no sense to me   :lol:

where do the decimal points come from ?
maybe provide some explanation for each step
Title: Re: The conversion of a binary number of to decimal
Post by: Mikl__ on May 22, 2015, 01:44:52 PM
Hi, dedndave!
it is not a decimal point, it is to separate the next digit to multiply, at each step, we move the point to next digit
conversion of a decimal number of to  binary
remember power of 2 (210=1024, 29=512, ... 23=8). For example, convert decimal number 147 to binary, 27=128<147<28=512
12345678
147/128=1 remainder 191
19/64=0 remainder 19    10
19/32=0 remainder 19    100
19/16=1 remainder 3      1001
3/8=0 remainder 3          10010
3/4=0 remainder 3          100100
3/2=1 remainder 1          1001001
1/1=1                              10010011
14710=
100100112
Title: Re: The conversion of a binary number of to decimal
Post by: dedndave on May 22, 2015, 02:16:36 PM
division is slow - work it in the opposite direction
but, you are just assigning a value for each bit - nothing new, there
Title: Re: The conversion of a binary number of to decimal
Post by: Mikl__ on May 22, 2015, 05:46:31 PM
dedndave,
of course, nothing new, because there is a built-in Windows calculator (http://www.cyberforum.ru/images/smilies/ap.gif)
Title: Re: The conversion of a binary number of to decimal
Post by: dedndave on May 22, 2015, 09:12:51 PM
if you want to work on base conversion between any bases, google for "horner's rule base conversion"
Title: Re: The conversion of a binary number of to decimal
Post by: Mikl__ on May 23, 2015, 10:01:50 AM
Quote from: dedndavegoogle for "horner's rule base conversion"
dedndave,
thank you, but I know it (http://www.cyberforum.ru/images/smilies/yes.gif)