Download EE313 Lecture 2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

History of logarithms wikipedia , lookup

Addition wikipedia , lookup

Arithmetic wikipedia , lookup

Location arithmetic wikipedia , lookup

Elementary mathematics wikipedia , lookup

Approximations of π wikipedia , lookup

Positional notation wikipedia , lookup

Transcript
EE313 Lecture 2
Covered Material
Least Significant Bit (LSB) is the far right bit
Most Significant Bit (MSB) is the far left bit
MSB
LSB
100010112
**Example (Binary to Decimal)
𝟏𝟏𝟏𝟎𝟏𝟏𝟎𝟏𝟐
*Starting with the LSB
𝟏𝒙𝟐𝟎 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟐 + 𝟏𝒙𝟐𝟑 + 𝟎𝒙𝟐𝟒 + 𝟏𝒙𝟐𝟓 + 𝟏𝒙𝟐𝟔 + 𝟏𝒙𝟐𝟕 =
𝟏 + 𝟎 + 𝟒 + 𝟖 + 𝟎 + 𝟑𝟐 + 𝟔𝟒 + 𝟏𝟐𝟖 = 𝟐𝟑𝟕𝟏𝟎
**Example (Decimal to Binary)
𝟐𝟑𝟕𝟏𝟎
Divide by Desired Base
𝟐𝟑𝟕 ÷ 𝟐 = 𝟏𝟏𝟖
𝟏𝟏𝟖 ÷ 𝟐 = 𝟓𝟗
𝟓𝟗 ÷ 𝟐 = 𝟐𝟗
𝟐𝟗 ÷ 𝟐 = 𝟏𝟒
𝟏𝟒 ÷ 𝟐 = 𝟕
𝟕÷𝟐=𝟑
𝟑÷𝟐=𝟏
𝟏÷𝟐=𝟎
𝟐𝟑𝟕𝟏𝟎 = 𝟏𝟏𝟏𝟎𝟏𝟏𝟎𝟏𝟐
Remainder times Base
Output
=
1 (LSB)
𝟎. 𝟎 𝒙 𝟐
=
0
=
1
𝟎. 𝟓 𝒙 𝟐
=
1
𝟎. 𝟎 𝒙 𝟐
=
0
=
1
𝟎. 𝟓 𝒙 𝟐
=
1
=
1 (MSB)
𝟎. 𝟓 𝒙 𝟐
𝟎. 𝟓 𝒙 𝟐
𝟎. 𝟓 𝒙 𝟐
𝟎. 𝟓 𝒙 𝟐
Practice Problems
1) Convert Binary to Decimal
a. 𝟏𝟏𝟎𝟏𝟏𝟎𝟐
b. 𝟎𝟎𝟎𝟏𝟏𝟏𝟎𝟏𝟐
2) Convert Decimal to Binary
a. 𝟒𝟔𝟓𝟏𝟎
b. 𝟏𝟐𝟑𝟓𝟏𝟎
New Material
Octal Numbering System (Base 8) is a method to group binary numbers in groups of three.
Start grouping with LSB; if grouping at the MSB is less than three Bits then add zeros to
complete the three Bit grouping. Allowable digits {0,1,2,3,4,5,6,7}.
**Example (Binary to Octal)
𝟏𝟏𝟏𝟏𝟎𝟏𝟐 = {𝟏𝟏𝟏} {𝟏𝟎𝟏} = {𝟏𝒙𝟐𝟐 + 𝟏𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 } {𝟏𝒙𝟐𝟐 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 } = {𝟕} {𝟓}
= 𝟕𝟓𝟖
𝟏𝟏𝟏𝟏𝟏𝟎𝟏𝟐 = {𝟎𝟎𝟏} {𝟏𝟏𝟏} {𝟏𝟎𝟏}
= {𝟎𝒙𝟐𝟐 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 } {𝟏𝒙𝟐𝟐 + 𝟏𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 } {𝟏𝒙𝟐𝟐 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 }
= {𝟏} {𝟕} {𝟓} = 𝟏𝟕𝟓𝟖
**Example (Octal to Binary)
𝟓𝟏𝟐𝟖 = {𝟓} {𝟏} {𝟐} = {𝟏𝟎𝟏} {𝟎𝟎𝟏} {𝟎𝟏𝟎} = 𝟏𝟎𝟏𝟎𝟎𝟏𝟎𝟏𝟎𝟐
**Example (Decimal to Octal)
𝟐𝟗𝟒𝟏𝟎
Divide by Desired Base
Remainder times Base
Output
𝟐𝟗𝟒 ÷ 𝟖 = 𝟑𝟔
𝟎. 𝟕𝟓 𝒙 𝟖
=
6 (LSB)
=
4
𝟒÷𝟖=𝟎
𝟎. 𝟓𝟎 𝒙 𝟖
=
4 (MSB)
𝟑𝟔 ÷ 𝟖 = 𝟒
𝟐𝟗𝟒𝟏𝟎 = 𝟒𝟒𝟔𝟖
𝟎. 𝟓𝟎 𝒙 𝟖
**Example (Octal to Decimal)
𝟕𝟒𝟓𝟖 = 𝟕𝒙𝟖𝟐 + 𝟒𝒙𝟖𝟏 + 𝟓𝒙𝟖𝟎 = 𝟒𝟒𝟖 + 𝟑𝟐 + 𝟓 = 𝟒𝟖𝟓𝟏𝟎
Practice Problems
1) True/False Question
a. Is {𝟗𝟐𝟑𝟖 } a valid Number?
b. Is {𝟕𝟖𝟏𝟖 } a valid Number?
c. Is {𝟕𝟔𝟕𝟖 } a valid Number?
2) Convert to Decimal
a. 𝟐𝟔𝟕𝟖
3) Convert to Octal
a. 𝟏𝟎𝟎𝟏𝟏𝟏𝟏𝟐
b. 𝟔𝟏𝟏𝟏𝟎
Hexadecimal Numbering System (Base 16) is a method to group binary numbers in groups of
four. Start grouping with LSB; if grouping at the MSB is less than four Bits then add zeros to
complete the four Bit grouping. Allowable digits {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}.
**Example (Binary to Hex)
𝟏𝟏𝟏𝟏𝟎𝟏𝟐 = {𝟎𝟎𝟏𝟏} {𝟏𝟏𝟎𝟏}
= {𝟎𝒙𝟐𝟑 + 𝟎𝒙𝟐𝟐 + 𝟏𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 } {𝟏𝒙𝟐𝟑 + 𝟏𝒙𝟐𝟐 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 }
= {𝟑} {𝟏𝟑 = 𝑫} = 𝟑𝑫𝟏𝟔
**Example (Hex to Binary)
𝟓𝟏𝟐𝟏𝟔 = {𝟓} {𝟏} {𝟐} = {𝟎𝟏𝟎𝟏} {𝟎𝟎𝟎𝟏} {𝟎𝟎𝟏𝟎} = 𝟏𝟎𝟏𝟎𝟎𝟎𝟏𝟎𝟎𝟏𝟎𝟐
𝑭𝑭𝟑𝟏𝟔 = {𝑭} {𝑭} {𝟑} = {𝟏𝟏𝟏𝟏} {𝟏𝟏𝟏𝟏} {𝟎𝟎𝟏𝟏} = 𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟏𝟎𝟎𝟏𝟏𝟐
**Example (Decimal to Hex)
𝟐𝟗𝟔𝟖𝟏𝟎
Divide by Desired Base
Remainder times Base
𝟐𝟗𝟔𝟖 ÷ 𝟏𝟔 = 𝟏𝟖𝟓
𝟎. 𝟓𝟎𝟎𝟎 𝒙 𝟏𝟔
𝟏𝟏 ÷ 𝟏𝟔 = 𝟎
𝟎. 𝟔𝟖𝟕𝟓 𝒙 𝟏𝟔
𝟏𝟖𝟓 ÷ 𝟏𝟔 = 𝟏𝟏
𝟐𝟗𝟔𝟖𝟏𝟎 = 𝑩𝟗𝟖𝟏𝟔
𝟎. 𝟓𝟔𝟐𝟓 𝒙 𝟏𝟔
Output
=
8 (LSB)
=
9
=
B (MSB)
**Example (Hex to Decimal)
𝟖𝟏𝟐𝑫𝟏𝟔 = 𝟖𝒙𝟏𝟔𝟑 + 𝟏𝒙𝟏𝟔𝟐 + 𝟐𝒙𝟏𝟔𝟏 + 𝟏𝟑𝒙𝟏𝟔𝟎 = 𝟑𝟐𝟕𝟔𝟖 + 𝟐𝟓𝟔 + 𝟑𝟐 + 𝟏𝟑 = 𝟑𝟑𝟎𝟔𝟗𝟏𝟎
**Example (Octal to Hex) --First convert to Binary and re-group then to Hexadecimal
𝟕𝟏𝟐𝟖 = {𝟕} {𝟏} {𝟐} = {𝟏𝟏𝟏} {𝟎𝟎𝟏} {𝟎𝟏𝟎} = {𝟎𝟎𝟎𝟏} {𝟏𝟏𝟎𝟎} {𝟏𝟎𝟏𝟎} = {𝟏} {𝟏𝟐} {𝟏𝟎}
= {𝟏} {𝑪} {𝑨} = 𝟏𝑪𝑨𝟏𝟔
**Example (Hex to Octal) --First convert to Binary and re-group then to Octal
𝟓𝑭𝑫𝟏𝟔 = {𝟓} {𝑭} {𝑫} = {𝟓} {𝟏𝟓} {𝟏𝟑} = {𝟎𝟏𝟎𝟏} {𝟏𝟏𝟏𝟏} {𝟏𝟏𝟎𝟏}
= {𝟎𝟏𝟎} {𝟏𝟏𝟏} {𝟏𝟏𝟏} {𝟏𝟎𝟏} = {𝟐} {𝟕} {𝟕} {𝟓} = 𝟐𝟕𝟕𝟓𝟖
Practice Problems
1) True/False Question
a. Is {𝑭𝟑𝑭𝟏𝟔 } a valid Number?
b. Is {𝑨𝟑𝟏𝟖 } a valid Number?
c. Is {𝟐𝟓𝑮𝟏𝟔 } a valid Number?
2) Convert to Decimal
a. 𝟐𝟔𝟕𝑩𝟏𝟔
3) Convert to Hex
a. 𝟏𝟎𝟎𝟏𝟏𝟏𝟏𝟐
b. 𝟔𝟏𝟏𝟏𝟎
Binary-Coded-Decimal (BCD) System is used to represent each of the 10 decimal digits as a
four Bit binary code. Allowable digits for each grouping {0,1,2,3,4,5,6,7,8,9 }.
**Example (Decimal to BCD)
𝟑𝟗𝟗𝟏𝟎 = {𝟎𝟎𝟏𝟏} {𝟏𝟎𝟎𝟏} {𝟏𝟎𝟎𝟏} = 𝟎𝟎𝟏𝟏 𝟏𝟎𝟎𝟏 𝟏𝟎𝟎𝟏𝑩𝑪𝑫
**Example (BCD to Decimal)
𝟎𝟎𝟏𝟎 𝟎𝟏𝟎𝟏𝑩𝑪𝑫 = {𝟎𝒙𝟐𝟑 + 𝟎𝒙𝟐𝟐 + 𝟏𝒙𝟐𝟏 + 𝟎𝒙𝟐𝟎 } {𝟎𝒙𝟐𝟑 + 𝟏𝒙𝟐𝟐 + 𝟎𝒙𝟐𝟏 + 𝟏𝒙𝟐𝟎 }
= {𝟐} {𝟓} = 𝟐𝟓𝟏𝟎
Practice Problems
1) True/False Question
a. Is {𝟏𝟏𝟎𝟎 𝟎𝟏𝟎𝟏𝑩𝑪𝑫 } a valid Number?
b. Is {𝟎𝟎𝟏𝟏 𝟎𝟏𝟏𝟏 𝟏𝟎𝟎𝟏𝑩𝑪𝑫 } a valid Number?
c. Is {𝟎𝟏𝟎𝟏 𝟏𝟎𝟎𝟎 𝟏𝟎𝟏𝟏𝑩𝑪𝑫 } a valid Number?