Logic 1
Logic 1
Logic 1
1
Understanding Binary Numbers
Hexadecimal
(base16)
° Learn to convert between bases.
2
Decimal review
• Numbers consist of a bunch of digits, each with a weight
1 6 2 . 3 7 5 Digits
100 10 1 1/10 1/100 1/1000 Weights
• These weights are all powers of the base, which is 10. We can rewrite
this:
1 6 2 . 3 7 5 Digits
102 101 100 10-1 10-2 10-3 Weights
• To find the decimal value of a number, multiply each digit by its weight
and sum the products.
3
Converting decimal to binary
• To convert a decimal integer into binary, keep dividing by 2 until the
quotient is 0. Collect the remainders in reverse order.
• To convert a fraction, keep multiplying the fractional part by 2 until it
becomes 0. Collect the integer parts in forward order.
• Example: 162.375:
4
Binary and hexadecimal conversions
• Converting from hexadecimal to binary is easy: just replace each hex
digit with its equivalent 4-bit binary sequence.
261.3516 = 2 6 1 . 3 516
= 0010 0110 0001 . 0011 01012
• To convert from binary to hex, make groups of 4 bits, starting from the
binary point. Add 0s to the ends of the number if needed. Then, just
convert each bit group to its corresponding hex digit.
Hex to Decimal
8 7 C 9
x 16
128
+ 7
135
x 16
2,160
+ 12
2,172
x 16
34,752
+ 9
34,761Logic Circuits -Dr. Mohamad Alwan
10
5
Convert Decimal to Hex
34,76110 = 87C916
Questions
100101012 = ? (decimal)
6
Questions
100101012 = ? (decimal)
1 0 0 1 0 1 0 1
27 26 25 24 23 22 21 20
(149)10
Questions
85710 = ?16
7
Questions
BED16 = ?2
8
Logic Circuits -Dr. Mohamad Alwan 17
9
Exercise 1:
Convert these decimal numbers: 17.76 - 1958.56
- To binary
- To octal (directly from decimal)
- To hexadecimal (directly from decimal)
- To octal (from binary)
- To hexadecimal (from binary)
Exercise 2:
Find the decimal numerical values of:
- The binary numbers: 1101.1 - 101.0101 - 110101.101
- The octal numbers: 236 - 702.41 - 1011.1
- The hexadecimal numbers: A0B.5 – 1011.1 - FC3.0E
10