binary and decimal numbers feb0605
TRANSCRIPT
Binary and Decimal Binary and Decimal NumbersNumbers
yrosenthal.com/ppt/binary/Binary_and_Decimal_Numbers_feb0605.pptyrosenthal.com/ppt/binary/Binary_and_Decimal_Numbers_feb0605.ppt
2
What is a binary number?What is a binary number? A binary number is a number that includes only ones A binary number is a number that includes only ones
and zeroes.and zeroes. The number could be of any length The number could be of any length The following are all examples of binary numbersThe following are all examples of binary numbers
00 101011010111 010101001010101010 101111010110111101010101 01101011100110101110111000111000 000111000111
Another name for binary is base-2 (pronounced "base two") Another name for binary is base-2 (pronounced "base two")
3
What is a decimal number?What is a decimal number?
The numbers that we are used to seeing are called The numbers that we are used to seeing are called decimal numbers.decimal numbers.
decimal numbers consist of the digits from 0 (zero) decimal numbers consist of the digits from 0 (zero) through 9.through 9.
The following are examples of decimal #'rsThe following are examples of decimal #'rs
33 76761515 3242323432423234890890 5353
Another name for decimal numbers are base-10 Another name for decimal numbers are base-10 (pronounced "base ten") numbers.(pronounced "base ten") numbers.
4
Equivalence of Binary and Equivalence of Binary and DecimalDecimal
Every Binary number has a corresponding Every Binary number has a corresponding Decimal value (and vice versa)Decimal value (and vice versa)
Examples:Examples:
Binary NumberBinary Number Decimal EquivalentDecimal Equivalent11 111010 221111 33…… ……10101111010111 8787
5
The value of a binary numberThe value of a binary number
Even though they look exactly the same, the value Even though they look exactly the same, the value of theof the binary number, 101 binary number, 101, is , is differentdifferent from the from the value of the value of the decimal number, 101decimal number, 101. . The value of the binary number, 101, is equal to the The value of the binary number, 101, is equal to the
decimal number five (i.e. 5)decimal number five (i.e. 5) The value of the decimal number, 101, is equal to one The value of the decimal number, 101, is equal to one
hundred and onehundred and one
When you see a number that consists of only ones When you see a number that consists of only ones and zeroes, you must be told if it is a binary and zeroes, you must be told if it is a binary number or a decimal number.number or a decimal number.
Computers store Computers store information using binary information using binary
numbersnumbers
7
All information on computers is All information on computers is stored as numbersstored as numbers
All informationAll information that is processed by computers is that is processed by computers is converted in one way or another into a sequence of converted in one way or another into a sequence of numbers. This includes numbers. This includes Numeric informationNumeric information Textual information andTextual information and PicturesPictures
(We’ll see later how text and pictures can be converted (We’ll see later how text and pictures can be converted into simple numbers … for now just take our word for it.)into simple numbers … for now just take our word for it.)
Therefore, if we can derive a way to store and retrieve Therefore, if we can derive a way to store and retrieve numbers electronically this method can be used by numbers electronically this method can be used by computers to store and retieve computers to store and retieve any type of information.any type of information.
How a computer stores How a computer stores informationinformation
9Binary Numbers are at the heart of Binary Numbers are at the heart of how a computer stores all how a computer stores all
informationinformation
Computers Store ALL information using Computers Store ALL information using Binary NumbersBinary Numbers
Computers use binary numbers in different Computers use binary numbers in different ways to store different types of ways to store different types of information.information.
10
What about a longer number?What about a longer number?
In general, the "position values" in a binary In general, the "position values" in a binary number are the powers of two.number are the powers of two.
The first position value is 2The first position value is 200 , i.e. one , i.e. one The 2nd position value is 2The 2nd position value is 21 1 , i.e. two, i.e. two The 2nd position value is 2The 2nd position value is 22 2 , i.e. four, i.e. four The 2nd position value is 2The 2nd position value is 23 3 , i.e. eight, i.e. eight The 2nd position value is 2The 2nd position value is 24 4 , i.e. sixteen, i.e. sixteen etc.etc.
Example on next slideExample on next slide
11
Some TerminologySome Terminology
The following are some terms that are The following are some terms that are used in the computer fieldused in the computer field
Each digit of a binary number is called a Each digit of a binary number is called a bitbit..
A binary number with eight bits (i.e. digits) is A binary number with eight bits (i.e. digits) is called a called a bytebyte..
12
How many different numbers?How many different numbers?
There are two different binary numbers with one bit:There are two different binary numbers with one bit: 00 11
There are four different binary numbers with two There are four different binary numbers with two bits:bits: 0000 (i.e. decimal 0)(i.e. decimal 0) 0101 (i.e. decimal 1)(i.e. decimal 1) 1010 (i.e. decimal 2)(i.e. decimal 2) 1111 (i.e. decimal 3)(i.e. decimal 3)
13
How many different numbers?How many different numbers?
There are eight different binary numbers with three There are eight different binary numbers with three bits:bits:
000000 (i.e. decimal 0)(i.e. decimal 0) 001001 (i.e. decimal 1)(i.e. decimal 1) 010010 (i.e. decimal 2)(i.e. decimal 2) 011011 (i.e. decimal 3)(i.e. decimal 3) 100100 (i.e. decimal 4)(i.e. decimal 4) 101101 (i.e. decimal 5)(i.e. decimal 5) 110110 (i.e. decimal 6)(i.e. decimal 6) 111111 (i.e. decimal 7)(i.e. decimal 7)
14
Different numbers - General RuleDifferent numbers - General Rule For n bits there are 2For n bits there are 2nn different binary numbers: different binary numbers:
# of bits# of bits # of different binary numbers# of different binary numbers1 bit: 1 bit: 2 211 = 2 = 2 2 bits: 2 bits: 2 222 = 4 = 4 3 bits: 3 bits: 2 233 = 8 = 8 4 bits: 4 bits: 2 244 = 16 = 165 bits: 5 bits: 2 255 = 32 = 326 bits: 6 bits: 2 266 = 64 = 647 bits: 7 bits: 2 277 = 128 = 1288 bits: 8 bits: 2 288 = 256 = 2569 bits: 9 bits: 2 299 = 512 = 51210 bits: 10 bits: 2 21010 = 1024 = 1024etc.etc.
15
Smallest value for a binary Smallest value for a binary
The smallest value for a binary number of The smallest value for a binary number of any number of bits is zero.any number of bits is zero.
This is the case when all bits are zero:This is the case when all bits are zero:
16
Smallest value for a binary Smallest value for a binary The smallest value for a binary number with any number of The smallest value for a binary number with any number of
bits is zero (i.e. when all the bits are zeros)bits is zero (i.e. when all the bits are zeros)
# of bits# of bits smallest binary #smallest binary # decimal valuedecimal value
1 bit:1 bit: 00 002 bits:2 bits: 0000 003 bits:3 bits: 000000 004 bits:4 bits: 00000000 005 bits:5 bits: 0000000000 006 bits:6 bits: 000000000000 007 bits:7 bits: 00000000000000 008 bits:8 bits: 0000000000000000 00etc.etc.
17
Largest value for a binary Largest value for a binary
The largest value for a binary number with The largest value for a binary number with a specific number of bits (i.e. digits) is a specific number of bits (i.e. digits) is when all of the bits are one.when all of the bits are one.
General rule: for a binary number with n General rule: for a binary number with n bits, the largest possible value is : bits, the largest possible value is : 22nn - 1 - 1
18
Largest numbersLargest numbers The following are the largest values for binary numbers with a The following are the largest values for binary numbers with a
specific number of bits:specific number of bits:
# of bits# of bits largest binary #largest binary # decimal valuedecimal value
1 bit:1 bit: 11 112 bits:2 bits: 1111 333 bits:3 bits: 111111 774 bits:4 bits: 11111111 15155 bits:5 bits: 1111111111 31316 bits:6 bits: 111111111111 63637 bits:7 bits: 11111111111111 1271278 bits:8 bits: 1111111111111111 255255etc.etc.
19
Converting a decimal to a binaryConverting a decimal to a binary
Step 1: figure out how many bits you will need Step 1: figure out how many bits you will need (see the chart on the previous slide).(see the chart on the previous slide).
Example 1: To convert the decimal number Example 1: To convert the decimal number 1616 to to binary, you will need at least 5 bits.binary, you will need at least 5 bits. (With 4 bits you can only store numbers up to (With 4 bits you can only store numbers up to 1515 but but with 5 bits you can store numbers up to with 5 bits you can store numbers up to 3131))
Example 2: To convert the decimal number Example 2: To convert the decimal number 106106 to to binary, you will need at least 7 bits.binary, you will need at least 7 bits. (With 6 bits you can only store numbers up to (With 6 bits you can only store numbers up to 6363 but but with 7 bits you can store numbers up to with 7 bits you can store numbers up to 127127))
20
Why is it called "binary" (or Why is it called "binary" (or base-2)?base-2)?
The prefix "bi" means "The prefix "bi" means "twotwo" in Latin" in Latin
Binary derives its name from the fact that Binary derives its name from the fact that the digits in a "the digits in a "BiBinary" number can only nary" number can only have have twotwo possible values, 0 or 1 possible values, 0 or 1
It is also called "base-It is also called "base-22" based on the fact " based on the fact that the column values are the powers of that the column values are the powers of 2.2. (i.e. (i.e. 2200 2211 2222 2233 2244 2255 etc. ) etc. )
Binary to Decimal ConversionBinary to Decimal Conversion
1101100111011001 0000111100001111 1100000011000000
Decimal to Binary ConversionDecimal to Binary Conversion
225225 130130 7070