U2 Lesson 2 Binary Number System Slides PDF
Document Details

Uploaded by AffordableModernism5372
Tags
Summary
These slides cover the binary number system, explaining its use in computers and how numbers are represented. Conversions between binary and decimal are discussed and illustrated with examples.
Full Transcript
 [Today's Objectives:] Students will understand why we convert between binary and decimal representations for digital data. Students will be able to convert between binary and decimal representations of numbers. Students will define and differentiate between logic erro...
 [Today's Objectives:] Students will understand why we convert between binary and decimal representations for digital data. Students will be able to convert between binary and decimal representations of numbers. Students will define and differentiate between logic errors, syntax errors, and run-time errors in programming. Students will be able to explain the concept of an overflow error and how it occurs in numeric representations. Decimal vs Binary Decimal vs Binary ∙ [Base-10] number system is referred to as [Decimal] and has 10 digits: [0 -- 9] Decimal vs Binary ∙ [Base-10] number system is referred to as [Decimal] and has 10 digits: [0 -- 9] ∙ [Base-2] number system is referred to as [Binary] and has 2 digits: [0 and 1] ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: o Learning to convert between decimal and binary helps programmers understand how values are stored and manipulated within a computer\'s memory. ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: o Learning to convert between decimal and binary helps programmers understand how values are stored and manipulated within a computer\'s memory. o Understanding how to convert between decimal and binary can help optimize storage space and design more efficient data compression algorithms. ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: o Learning to convert between decimal and binary helps programmers understand how values are stored and manipulated within a computer\'s memory.  o Understanding how to convert between decimal and binary can help optimize storage space and design more efficient data compression algorithms. o Converting between decimal and binary is essential for understanding how data is encoded and decoded during online communication. ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: o Learning to convert between decimal and binary helps programmers understand how values are stored and manipulated within a computer\'s memory. o Understanding how to convert between decimal and binary can help optimize storage space and design more efficient data compression algorithms. o Converting between decimal and binary is essential for understanding how data is encoded and decoded during online communication. o Converting between decimal and binary is crucial for designing and understanding digital circuits and logic gates. ∙ Understanding and performing conversions between decimal and binary number systems provide insights into how computers process and store data: o Learning to convert between decimal and binary helps programmers understand how values are stored and manipulated within a computer\'s memory.  o Understanding how to convert between decimal and binary can help optimize storage space and design more efficient data compression algorithms. o Converting between decimal and binary is essential for understanding how data is encoded and decoded during online communication. o Converting between decimal and binary is crucial for designing and understanding digital circuits and logic gates. o Converting between decimal and binary exercises logical thinking and problem-solving skills. ∙ In today\'s digital world, basic knowledge of binary and its conversion from/to decimal is a form of digital literacy. ∙ In today\'s digital world, basic knowledge of binary and its conversion from/to decimal is a form of digital literacy. ∙ While we don\'t typically perform manual conversions in day-to day tasks due to technology, a foundational understanding of converting between decimal and binary can be useful in understanding computer-related concepts. Representing Numbers ∙ The decimal number system and has 10 digits: 0 -- 9 Representing Numbers ∙ The decimal number system and has 10 digits: 0 -- 9 ∙ We can represent every number we can think of with [10 digits]  Representing Numbers ∙ The decimal number system and has 10 digits: 0 -- 9 ∙ We can represent every number we can think of with [10 digits] ∙ Every number we can think of can be broken down into a base-10 representation Breakdown the following decimal numbers into their base-10 representation ---- ----- ------ 84 225 1376 ---- ----- ------ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | | | | | | | | 8 ∙ 10^1^ + | | | | | | | | 4 ∙ 10^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | 200 + 20 + 5 | | | | | | | 8 ∙ 10^1^ + | | | | | | | | 4 ∙ 10^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | 200 + 20 + 5 | | | | | | | 8 ∙ 10^1^ + | 2 ∙ 10^2^ + | | | | | | | 4 ∙ 10^0^ | 2 ∙ 10^1^ + | | | | | | | | 5 ∙ 10^0^ | | +-----------------------+-----------------------+-----------------------+ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | 200 + 20 + 5 | 1000 + 300 + 70 + 6 | | | | | | 8 ∙ 10^1^ + | 2 ∙ 10^2^ + | | | | | | | 4 ∙ 10^0^ | 2 ∙ 10^1^ + | | | | | | | | 5 ∙ 10^0^ | | +-----------------------+-----------------------+-----------------------+ Breakdown the following decimal numbers into their base-10 representation +-----------------------+-----------------------+-----------------------+ | 84 | 225 | 1376 | | | | | | 80 + 4 | 200 + 20 + 5 | 1000 + 300 + 70 + 6 | | | | | | 8 ∙ 10^1^ + | 2 ∙ 10^2^ + | 1 ∙ 10^3^ + | | | | | | 4 ∙ 10^0^ | 2 ∙ 10^1^ + | 3 ∙ 10^2^ + | | | | | | | 5 ∙ 10^0^ | 7 ∙ 10^1^ + | | | | | | | | 6 ∙ 10^0^ | +-----------------------+-----------------------+-----------------------+ ∙ As you can infer, we can represent any whole number we know with its base 10 equivalent. ∙ As you can infer, we can represent any whole number we know with its base 10 equivalent. ∙ In the binary number system, representing numbers works similarly, just with [a base of 2] instead of 10. ∙ As you can infer, we can represent any whole number we know with its base 10 equivalent. ∙ In the binary number system, representing numbers works similarly, just with [a base of 2] instead of 10. ∙ The binary number system has 2 digits: 0 and 1 ∙ As you can infer, we can represent any whole number we know with its base 10 equivalent. ∙ In the binary number system, representing numbers works similarly, just with [a base of 2] instead of 10. ∙ The binary number system has 2 digits: 0 and 1 ∙ We can still represent every whole number we know (and even the decimals) with just these two digits ∙ As you can infer, we can represent any whole number we know with its base 10 equivalent. ∙ In the binary number system, representing numbers works similarly, just with [a base of 2] instead of 10. ∙ The binary number system has 2 digits: 0 and 1 ∙ We can still represent every whole number we know (and even the decimals) with just these two digits ∙ Each digit is a place holder like the decimal representation above, it is just that the base number is now \"2\" instead of 10. Breakdown the following binary numbers into their base-2 representation: ------ ------ ----- 1101 1001 100 ------ ------ ----- Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | | | | | | if we evaluated this: | | | | | | | | 8 + 4 + 0 + 1 | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | | | | | | if we evaluated this: | | | | | | | | 8 + 4 + 0 + 1 = 13 in | | | | decimal | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | | | | | if we evaluated this: | | | | | | | | 8 + 4 + 0 + 1 = 13 in | | | | decimal | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | | | | | if we evaluated this: | if we evaluated this: | | | | | | | 8 + 4 + 0 + 1 = 13 in | 8 + 0 + 0 + 1 | | | decimal | | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | | | | | | | if we evaluated this: | if we evaluated this: | | | | | | | 8 + 4 + 0 + 1 = 13 in | 8 + 0 + 0 + 1 = 9 in | | | decimal | decimal | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | 1 ∙ 2^2^ + 0 ∙ 2^1^ + | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^0^ | | | | | | if we evaluated this: | if we evaluated this: | | | | | | | 8 + 4 + 0 + 1 = 13 in | 8 + 0 + 0 + 1 = 9 in | | | decimal | decimal | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | 1 ∙ 2^2^ + 0 ∙ 2^1^ + | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^0^ | | | | | | if we evaluated this: | if we evaluated this: | if we evaluated this: | | | | | | 8 + 4 + 0 + 1 = 13 in | 8 + 0 + 0 + 1 = 9 in | 4 + 0 + 0 | | decimal | decimal | | +-----------------------+-----------------------+-----------------------+ Breakdown the following binary numbers into their base-2 representation: +-----------------------+-----------------------+-----------------------+ | 1101 | 1001 | 100 | | | | | | 1 ∙ 2^3^ + 1 ∙ 2^2^ + | 1 ∙ 2^3^ + 0 ∙ 2^2^ + | 1 ∙ 2^2^ + 0 ∙ 2^1^ + | | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^1^ + 1 ∙ 2^0^ | 0 ∙ 2^0^ | | | | | | if we evaluated this: | if we evaluated this: | if we evaluated this: | | | | | | 8 + 4 + 0 + 1 = 13 in | 8 + 0 + 0 + 1 = 9 in | 4 + 0 + 0 = 4 in | | decimal | decimal | decimal | +-----------------------+-----------------------+-----------------------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | | | | | | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | | | | | | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | | | | | | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | | | | | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | | | | | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | | | | | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | | | | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | | | | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | | | | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | | | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | | | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | | | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | | 4th | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | | 2^3^ | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | | 8 | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | | 5th | 4th | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | | 2^4^ | 2^3^ | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | | 16 | 8 | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | | 6th | 5th | 4th | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | | 2^5^ | 2^4^ | 2^3^ | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | | 32 | 16 | 8 | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | | 7th | 6th | 5th | 4th | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | | 2^6^ | 2^5^ | 2^4^ | 2^3^ | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | | 64 | 32 | 16 | 8 | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ Each position is called a bit and they are commonly grouped together in bytes (8 bits) ∙ On paper, we sometimes put a space between a byte which makes a group of 4 bits (called a [nibble]) that are then easier to read +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Bina | 8th | 7th | 6th | 5th | 4th | 3rd | 2nd | 1st | | ry* | | | | | | | | | | | | | | | | | | | | *Posi | | | | | | | | | | tion* | | | | | | | | | +=======+=======+=======+=======+=======+=======+=======+=======+=======+ | *Base | 2^7^ | 2^6^ | 2^5^ | 2^4^ | 2^3^ | 2^2^ | 2^1^ | 2^0^ | | 2* | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ | *Deci | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 | | mal* | | | | | | | | | | | | | | | | | | | | *Repr | | | | | | | | | | esent | | | | | | | | | | ation | | | | | | | | | | * | | | | | | | | | +-------+-------+-------+-------+-------+-------+-------+-------+-------+ ∙ To differentiate between the decimal number 1101 (one thousand one hundred and one) and the binary number 1101, we use a subscript system: ∙ To differentiate between the decimal number 1101 (one thousand one hundred and one) and the binary number 1101, we use a subscript system: ∙ 1101~10~ is one thousand one hundred and one (1,101) ∙ To differentiate between the decimal number 1101 (one thousand one hundred and one) and the binary number 1101, we use a subscript system:  ∙ 1101~10~ is one thousand one hundred and one (1,101) ∙ 1101~2~is the binary number 1101 which is thirteen in decimal (13) Make Flip Do! Binary to Decimal Conversions When converting from binary to decimal, think of this: Which base-2 positions are "switched on"? Make a table with two rows and up to 8 columns. Starting with 1 on the right most column, fill in the remaining top row with multiples of 2. Fill in the 1s and 0s in the second row. Add the products of row one and two. ----------- ----------- 1010 1101 0010 1000 ----------- ----------- Binary to Decimal Conversions When converting from binary to decimal, think of this: Which base-2 positions are "switched on"? Make a table with two rows and up to 8 columns. Starting with 1 on the right most column, fill in the remaining top row with multiples of 2. Fill in the 1s and 0s in the second row. Add the products of row one and two. +-----------------------------------+-----------------------------------+ | 1010 1101 | 0010 1000 | | | | | 128 64 32 16 8 4 2 1 1 0 1 0 1 1 | 128 64 32 16 8 4 2 1 0 0 1 0 1 0 | | 0 1 | 0 0 | | | | | 128 + 32 + 8 + 4 + 1 = 173 | 32 + 8 = 40 | +-----------------------------------+-----------------------------------+ What is the largest number we can hold in one byte? What is the largest number we can hold in one byte? 1111 1111 What is the largest number we can hold in one byte? 1111 1111 = 2^7^ + 2^6^ + 2^5^ + 2^4^ + 2^3^ + 2^2^ + 2^1^ + 2^0^ What is the largest number we can hold in one byte? 1111 1111 = 2^7^ + 2^6^ + 2^5^ + 2^4^ + 2^3^ + 2^2^ + 2^1^ + 2^0^ = 128 + 64 + 32+ 16 + 8 + 4 + 2 + 1 = 255 What is the largest number we can hold in one byte? 1111 1111 = 2^7^ + 2^6^ + 2^5^ + 2^4^ + 2^3^ + 2^2^ + 2^1^ + 2^0^ = 128 + 64 + 32+ 16 + 8 + 4 + 2 + 1 = 255 numbers can be represented using one byte: [0 to 255] +-----------------+-----------------+-----------------+-----------------+ | \# of bits ( ) | Largest | Largest | Total \# of | | | | | numbers that | | | possible \# | possible \# | can be | | | | | represented | | | (binary) | (decimal) | | +=================+=================+=================+=================+ | 1 | 1 | 1 | 2 | +-----------------+-----------------+-----------------+-----------------+ | 2 | 11 | | | +-----------------+-----------------+-----------------+-----------------+ | 3 | 111 | | | +-----------------+-----------------+-----------------+-----------------+ | 4 | 1111 | | | +-----------------+-----------------+-----------------+-----------------+ | 5 | 1 1111 | | | +-----------------+-----------------+-----------------+-----------------+ | 6 | 11 1111 | | | +-----------------+-----------------+-----------------+-----------------+ | 7 | 111 1111 | | | +-----------------+-----------------+-----------------+-----------------+ | 8 | 1111 1111 | | | +-----------------+-----------------+-----------------+-----------------+ | | 1111....1111 | | | +-----------------+-----------------+-----------------+-----------------+ +-----------------+-----------------+-----------------+-----------------+ | \# of bits ( ) | Largest | Largest | Total \# of | | | | | numbers that | | | possible \# | possible \# | can be | | | | | represented | | | (binary) | (decimal) | | +=================+=================+=================+=================+ | 1 | 1 | 1 | 2 | +-----------------+-----------------+-----------------+-----------------+ | 2 | 11 | 3 | 4 | +-----------------+-----------------+-----------------+-----------------+ | 3 | 111 | 7 | 8 | +-----------------+-----------------+-----------------+-----------------+ | 4 | 1111 | 15 | 16 | +-----------------+-----------------+-----------------+-----------------+ | 5 | 1 1111 | 31 | 32 | +-----------------+-----------------+-----------------+-----------------+ | 6 | 11 1111 | 63 | 64 | +-----------------+-----------------+-----------------+-----------------+ | 7 | 111 1111 | 127 | 128 | +-----------------+-----------------+-----------------+-----------------+ | 8 | 1111 1111 | 255 | 256 | +-----------------+-----------------+-----------------+-----------------+ | | 1111....1111 | 2^ ^ − 1 | 2^ ^ | +-----------------+-----------------+-----------------+-----------------+ When a new bit is added, we double the total number of numbers that can be represented. **^Binary\ to\ Decimal\ Conversion:\ Practice^**Try on 0001 0101 0011 0101your own! ----------- -------------------- 0101 0110 0001 1111 **Binary to Decimal Conversion: Practice** +-----------------------------------+-----------------------------------+ | 0001 0101 | 0011 0101 | | | | | 128 64 32 16 8 4 2 1 0 0 0 1 0 1 | 128 64 32 16 8 4 2 1 0 0 1 1 0 1 | | 0 1 | 0 1 | | | | | 16 + 4 + 1 = 21 | 32 + 16 + 4 + 1 = 53 | +===================================+===================================+ | 0101 0110 | 0001 1111 | | | | | 128 64 32 16 8 4 2 1 0 1 0 1 0 1 | 128 64 32 16 8 4 2 1 0 0 0 1 1 1 | | 1 0 | 1 1 | | | | | 64 + 16 + 4 + 2 = 86 | 16 + 8 + 4 + 2 + 1 = 31 | | | | | | OR 32 -- 1 = 31 | +-----------------------------------+-----------------------------------+ Decimal to Binary Conversions ∙ Make a table similar to before: two rows and enough columns so that the number at the top is bigger than the number to convert ∙ Turn \"on\" the one that\'s the largest number less than the number to convert ∙ Subtract ∙ Repeat until you get 0 ---- ---- 20 45 ---- ---- Decimal to Binary Conversions ∙ Make a table similar to before: two rows and enough columns so that the number at the top is bigger than the number to convert ∙ Turn \"on\" the one that\'s the largest number less than the number to convert ∙ Subtract ∙ Repeat until you get 0 +-----------------------------------+-----------------------------------+ | 20 | 45 | | | | | 32 16 8 4 2 1 | 64 32 16 8 4 2 1 | | | | | 1 0 1 0 0 | 1 0 1 1 0 1 | | | | | 20 -- 16 = 4 | 45 -- 32 = 13 | | | | | 4 -- 4 = 0 | 13 -- 8 = 5 | | | | | Answer: 1 0100 | 5 -- 4 = 1 | | | | | | 1 -- 1 = 0 Answer: 10 1101 | +-----------------------------------+-----------------------------------+ **Decimal to Binary Conversion: Practice** 70 70 ÷ 2 = 45 R 0 101 101 ÷ 2 = 50 R 1 45 ÷ 2 = 22 R 1 50 ÷ 2 = 25 R 0 22 ÷ 2 = 11 R 0 25 ÷ 2 = 12 R 1 11 ÷ 2 = 5 R 1 12 ÷ 2 = 6 R 0 5 ÷ 2 = 2 R 1 6 ÷ 2 = 3 R 0 2 ÷ 2 = 1 R 0 3 ÷ 2 = 1 R 1 1 ÷ 2 = 0 R 1 1 ÷ 2 = 0 R 1 193 193 ÷ 2 = 96 R 1 204 Try on your own! **Decimal to Binary Conversion: Practice** +-----------------------------------+-----------------------------------+ | 70 | 101 | | | | | 128 64 32 16 8 4 2 1 1 0 0 0 1 1 | 128 64 32 16 8 4 2 1 1 1 0 0 1 0 | | 0 | 1 | | | | | 70 -- 64 = 6 | 101 -- 64 = 37 | | | | | 6 -- 4 = 2 | 37 -- 32 = 5 | | | | | 2 -- 2 = 0 Answer: 100 0110 | 5 -- 4 = 1 | | | | | | 1 -- 1 = 0 Answer: 110 0101 | +===================================+===================================+ | 193 | 204 | | | | | 256 128 64 32 16 8 4 2 1 1 1 0 0 | 256 128 64 32 16 8 4 2 1 1 1 0 0 | | 0 0 0 1193 -- 128 = 65 | 1 1 0 0 | | | | | 65 -- 64 = 1 | 204 -- 128 = 76 | | | | | 1 -- 1 = 0 Answer: 1100 0001 | 76 -- 64 = 12 | | | | | | 12 -- 8 = 4 | | | | | | 4 -- 4 = 0 Answer: 1100 1100 | +-----------------------------------+-----------------------------------+ Signed Numbers ∙ Binary digits can represent not only whole numbers but also other forms of data Signed Numbers ∙ Binary digits can represent not only whole numbers but also other forms of data ∙ For example, to represent signed integers, we can use the leftmost bit of a number to represent the sign: Signed Numbers ∙ Binary digits can represent not only whole numbers but also other forms of data ∙ For example, to represent signed integers, we can use the leftmost bit of a number to represent the sign: o0 meaning positive (+) Signed Numbers ∙ Binary digits can represent not only whole numbers but also other forms of data ∙ For example, to represent signed integers, we can use the leftmost bit of a number to represent the sign: o0 meaning positive (+) o1 meaning negative (−) Signed Numbers ∙ Binary digits can represent not only whole numbers but also other forms of data ∙ For example, to represent signed integers, we can use the leftmost bit of a number to represent the sign: o0 meaning positive (+) o1 meaning negative (−) ∙ The remaining bits are used to represent the magnitude of the value. For example, to represent the quantity −49, we could use seven binary digits with 1 bit for the sign and 6 bits for the magnitude: For example, to represent the quantity −49, we could use seven binary digits with 1 bit for the sign and 6 bits for the magnitude: 111 0001 For example, to represent the quantity −49, we could use seven binary digits with 1 bit for the sign and 6 bits for the magnitude: 1[11 0001] − (2^5^ + 2^4^ + 2^0^) For example, to represent the quantity −49, we could use seven binary digits with 1 bit for the sign and 6 bits for the magnitude: 1[11 0001] − (2^5^ + 2^4^ + 2^0^) − (32 + 16 + 1) = −49 For example, to represent the quantity −49, we could use seven binary digits with 1 bit for the sign and 6 bits for the magnitude: 1[11 0001] − (2^5^ + 2^4^ + 2^0^) − (32 + 16 + 1) = −49 How does the computer know that this is the number −49 instead of 113 (which would be the value if we counted the left most digit as 2^6^)?