CSE 111, Fall 2004
Algorithm: Convert 8-Bit Binary B to Decimal D
Last Update: 8 September 2004
Note:
or
material is highlighted
Input B;
Going from right to left, write the
decimal
values of the
binary
places underneath each place;
To do this, start by writing 1 under the first place on the right;
Then double each value as you move to the left;
Add the decimal values that are underneath 1's;
Let D = this number;
Output D;
Stop.
Test this with:
B = 11111111
B = 01101101
B = 10010010
B = 01111111
B = 00000010
B = 00000000
Question to think about:
Steps 2a and 2b are an attempt to make step 2 more precise. Can you explain it in even more detail?
Copyright © 2004 by
William J. Rapaport
(
rapaport@cse.buffalo.edu
)
file: 111F04/bin2dec-alg-2004-09-08.html