CSE 111, Fall 2004

ALGORITHM: DECIMAL D TO 8-BIT BINARY B

  1. Make a table with columns labeled:

  2. a) Write D in column (1);
    b) Write 128 (= 8th bit's place) in column (2);
    c) Do D ÷ 128;
    d) Get quotient Q & remainder R;
    e) Write Q in column (3)

  3. Repeat (until column 2 = "1")
               (i.e., until all bits are computed):

  4. Let b8, b7, ..., b1 be the numerals in column (3),
    from top to bottom

    Then B = b8 b7 ... b1.



Copyright © 2004 by William J. Rapaport (rapaport@cse.buffalo.edu)
file: 111F04/dec2bin-alg-2004-08-25.html