COP 3502
LAB # 2 Topics
Review of Decimal:
We have 10 digits[0..9] and the digit’s position in a number determines its overall value.
For example, the number 3714 means
3*1000 + 7*100 + 1*10 +4*1
or we can also write it as
3*10
3
+ 7*10
2
+ 1*10
1
+ 4*10
0
(where 10
0
=1).
Binary to Decimal:
The binary number system means that we have two digits[0,1] and that the digit’s
position also determines its value, but as a power of 2 instead of as a power of 10.
The number 1101 in binary is
1*2
3
+ 1*2
2
+ 0*2
1
+1*2
0
or
8 + 4 + 0 + 1 =13.
The number
001010 in binary is
We can convert any binary number into decimal by adding the values of each of its digits
just as we did in the example.
Dec to Binary:
Two methods to show this:
First, subtraction of the highest powers of two, keeping track of which you could and
couldn’t subtract.
For example 94:
94 is larger than 64 and is less than 128,
1
*2
6
so we do 9464=30.
(1)
You can’t subtract the next power, 32
0
*2
5
So
the 32’s position is a 0 (0)
30 is greater than the next power 16
1
*2
4
So we do 3016= 14
(1)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Summer '09
 Computer Science, Remainder, Power, Binary numeral system, Power of two

Click to edit the document details