News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

The conversion of a binary number of to decimal

Started by Mikl__, May 22, 2015, 01:21:15 PM

Previous topic - Next topic

Mikl__

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

dedndave

that makes no sense to me   :lol:

where do the decimal points come from ?
maybe provide some explanation for each step

Mikl__

#2
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

dedndave

division is slow - work it in the opposite direction
but, you are just assigning a value for each bit - nothing new, there

Mikl__

dedndave,
of course, nothing new, because there is a built-in Windows calculator

dedndave

if you want to work on base conversion between any bases, google for "horner's rule base conversion"

Mikl__

Quote from: dedndavegoogle for "horner's rule base conversion"
dedndave,
thank you, but I know it