binary and decimal numbers prof. rosenthal. 2 what is a binary number? a binary number is a number...
TRANSCRIPT
![Page 1: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/1.jpg)
Binary and Decimal Numbers
Prof. Rosenthal
![Page 2: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/2.jpg)
2
What is a binary number?• A binary number is a number that includes only ones and
zeroes.• The number could be of any length • The following are all examples of binary numbers
0 101011 010101010 101111010101 0110101110111000 000111
• Another name for binary is base-2 (pronounced "base two")
![Page 3: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/3.jpg)
3
What is a decimal number?• The numbers that we are used to seeing are called decimal
numbers.• decimal numbers consist of the digits from 0 (zero)
through 9.• The following are examples of decimal #'rs
3 7615 32423234890 53
• Another name for decimal numbers are base-10 (pronounced "base ten") numbers.
![Page 4: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/4.jpg)
4
Equivalence of Binary and Decimal• Every Binary number has a corresponding Decimal
value (and vice versa)
• Examples:
Binary Number Decimal Equivalent1 110 211 3… …1010111 87
![Page 5: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/5.jpg)
5
The value of a binary number
• Even though they look exactly the same, the value of the binary number, 101, is different from the value of the decimal number, 101. – The value of the binary number, 101, is equal to the decimal
number five (i.e. 5)
– The value of the decimal number, 101, is equal to one hundred and one
• When you see a number that consists of only ones and zeroes, you must be told if it is a binary number or a decimal number.
![Page 6: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/6.jpg)
Computers store information using binary numbers
![Page 7: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/7.jpg)
7
All information on computers is stored as numbers
• All information that is processed by computers is converted in one way or another into a sequence of numbers. This includes – numeric information– textual information and– Picutures
(We’ll see later how text and pictures can be converted into simple numbers … for now just take our word for it.)
• Therefore, if we can derive a way to store and retrieve numbers electronically this method can be used by computers to store and retieve any type of information.
![Page 8: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/8.jpg)
8
How does a CD store information?
• For detailed information about a CD works, see the following URL:
http://electronics.howstuffworks.com/cd.htm
• This presentation will only focus on the very basics.
![Page 9: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/9.jpg)
9
Information is stored using binary numbers
• A binary number is simply a bunch of 1’s and 0’s• CD’s that are created in a factory (we’re not talking
about CD-R’s yet) may look perfectly flat. However, there are many microscopic “bumps” on the surface of the CD.
• The bumps are laid out in a spiral form on the surface of the CD.
•
•
![Page 10: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/10.jpg)
How a computer stores information
![Page 11: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/11.jpg)
11
Binary Numbers are at the heart of how a computer stores all information
• Computers Store ALL information using Binary Numbers
• Computers use binary numbers in different ways to store different types of information.
• Common types of information that are stored by computers are :
– Whole numbers (i.e. Integers). Examples: 8 97 -732 0 -5 etc
– Numbers with decimal points. Examples: 3.5 -1.234 0.765 999.001 etc
– Textual information (including letters, symbols and digits)
• Keep reading …
![Page 12: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/12.jpg)
12
Integers
• Integers (e.g. 87)
A computer stores integer numbers (i.e. “whole” numbers) simply as the equivalent binary value for that number.
![Page 13: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/13.jpg)
13
Numbers with Decimal Points• Numbers with decimal points (e.g. 87.123)
– Internally, a computer stores a number with a decimal point as two different integer numbers (each stored using binary). To get the actual value, the computer performs a mathematical calculation using the two integers to derive the number.
– We will NOT discuss here the actual mathematical calculation nor how the computer breaks a number with a decimal point into two integers.
[NOTE: The two integers are NOT the whole number part and fractional part.]
![Page 14: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/14.jpg)
14
Letters and symbols
• Letters and symbols– To store letters and symbols, the computer assigns
every character on the keyboard a numerical value. – Computers remember letters and other symbols by
storing the binary number for the symbol.– For this system to work a standard numbering system
needs to be defined and consistently used for all symbols that the computer needs to process.
– See the following slide …
![Page 15: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/15.jpg)
15
ASCII (Americal Standard Code for Information Interchange)• ASCII (Americal
Standard Code for Information Interchange) is the standard numbering given to all characters on a standard keyboard.
• “ASCII values” range in number from 1 to 128. Some “ASCII values” and their associated symbols are listed to the right.
• Note that EVERY symbol on a standard keyboard has an ASCII value. Even the digits 0,1,2,…9 have ASCII values. (see next slide)
• 32 = Space• 33 = !• 34 = “• 35 = # • 36 = $• 37 = %• 38 = &• 39 = `• 40 = (• 41 = )• 42 = *• 43 = +• 44 = ,• 45 = -• 46 = .• 47 = /• 48 = 0• 49 = 1• 50 = 2• 51 = 3• 52 = 4• 53 = 5• 54 = 6• 55 = 7• 56 = 8• 57 = 9• 58 = :• 59 = ;• 60 = <• 61 = =• 62 = >• 63 = ?
• 64 = @• 65 = A• 66 = B• 67 = C• 68 = D • 69 = E• 70 = F• 71 = G• 72 = H• 73 = I• 74 = J• 75 = K• 76 = L• 77 = M• 78 = N• 79 = O• 80 = P• 81 = Q• 82 = R• 83 = S• 84 = T• 85 = U• 86 = V• 87 = W• 88 = X• 89 = Y• 90 = Z• 91 = [• 92 = \• 93 = ]• 94 = ^• 95 = _
• 96 = `• 97 = a• 98 = b• 99 = c• 100 = d • 101 = e• 102 = f • 103 = g• 104 = h• 105 = i• 106 = j• 107 = k• 108 = l• 109 = m• 110 = n• 111 = o• 112 = p• 113 = q• 114 = r• 115 = s• 116 = t• 117 = u• 118 = v• 119 = w• 120 = x• 121 = y• 122 = z• 123 = {• 124 = |• 125 = }• 126 = ~
Some ASCII values (values 1-31 and 128 are not shown)
![Page 16: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/16.jpg)
16
Why do 0 through 9 have ASCII values?• Numbers that are used in mathematical calculations
– If a computer needs to do math with a number it will store that number using the appropriate binary representation of the number.
– This makes it easier for the computer to perform mathematical calculations with the number.
– Example: 5 would be stored as
00000101
• Numbers that are NOT used in mathematical calculations– If the computer does NOT need to do math with the number (e.g. a zip code) then it
will generally store the number using the ASCII values of the digits.– In this case using the ASCII value is more efficient (for reasons we will not explain
here).– Example 5 would be stored using its ASCII value of 53 which is represented in
binary as
00110101
![Page 17: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/17.jpg)
17
Other numbering systems (Unicode and EBCDIC)
• ASCII– ASCII was the standard numbering system for many years and is still used widely today.
• EBCDIC– Is a different numbering system used by IBM Mainframe computers.– It is very similar to ASCII but uses different numbers to represent the symbols.– EBCDIC stands for “Extended Binary Coded Decimal Interchange Code”
• Unicode– ASCII and EBCDIC are limited to just the basic English letters and common symbols.– Today computers use many different symbols including letters from languages that don’t use
English letters (e.g. Hebrew, Chinese, etc.) and international symbols (e.g. the English pound sign)
– Unicode defines a unique number for every symbol in all known languages (e.g. Hebrew, Chinese, etc.) and commonly used non-letter symbols (e.g. English pound sign, copyright symbol, etc).
– Modern programs are moving towards using Unicode to store letters and symbols.– It should be noted that Unicode numbers 1-128 correspond to the EXACT SAME symbols as
ASCII 1-128
![Page 18: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/18.jpg)
How to Convert from Binary to Decimal
![Page 19: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/19.jpg)
19
Converting from binary to decimal• Each position for a binary number has a value.• For each digit, multiply the digit by its position value• Add up all of the products to get the final result• The decimal value of binary 101 is computed below:
4 2 1--------------------------------------
1 0 1
1 X 1 = 10 X 2 = 0
1 X 4 = 4---- 5
![Page 20: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/20.jpg)
20
What about a longer number?• In general, the "position values" in a binary number are
the powers of two.
– The first position value is 20 , i.e. one– The 2nd position value is 21 , i.e. two– The 2nd position value is 22 , i.e. four– The 2nd position value is 23 , i.e. eight– The 2nd position value is 24 , i.e. sixteen– etc.
• Example on next slide
![Page 21: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/21.jpg)
21
Example• The value of binary 01100001 is decimal 105. This is worked out below:
128 64 32 16 8 4 2 1----------------------------------------------------------------------
0 1 1 0 1 0 0 11 X 1 = 1
0 X 2 = 00 X 4 = 0
1 X 8 = 80 X 16 = 0
1 X 32 = 321 X 64 = 64
0 X 128 = 0----
Answer: 105
![Page 22: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/22.jpg)
22
Another example• The value of binary 10011100 is decimal 156. This is worked out below:
128 64 32 16 8 4 2 1----------------------------------------------------------------------
1 0 0 1 1 1 0 00 X 1 = 0
0 X 2 = 01 X 4 = 4
1 X 8 = 81 X 16 = 16
0 X 32 = 00 X 64 = 0
1 X 128 = 128----
Answer: 156
![Page 23: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/23.jpg)
23
Some Terminology
• The following are some terms that are used in the computer field
– Each digit of a binary number is called a bit.
– A binary number with eight bits (i.e. digits) is called a byte.
![Page 24: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/24.jpg)
24
How many different numbers?
• There are two different binary numbers with one bit:– 0
– 1
• There are four different binary numbers with two bits:– 00 (i.e. decimal 0)
– 01 (i.e. decimal 1)
– 10 (i.e. decimal 2)
– 11 (i.e. decimal 3)
![Page 25: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/25.jpg)
25
How many different numbers?
• There are eight different binary numbers with three bits:
– 000 (i.e. decimal 0)
– 001 (i.e. decimal 1)
– 010 (i.e. decimal 2)
– 011 (i.e. decimal 3)
– 100 (i.e. decimal 4)
– 101 (i.e. decimal 5)
– 110 (i.e. decimal 6)
– 111 (i.e. decimal 7)
![Page 26: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/26.jpg)
26
# different numbers - General Rule• For n bits there are 2n different binary numbers:
# of bits # of different binary numbers1 bit: 21 = 2 2 bits: 22 = 4 3 bits: 23 = 8 4 bits: 24 = 165 bits: 25 = 326 bits: 26 = 647 bits: 27 = 1288 bits: 28 = 2569 bits: 29 = 51210 bits: 210 = 1024etc.
![Page 27: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/27.jpg)
27
Smallest value for a binary #
• The smallest value for a binary number of any number of bits is zero.
• This is the case when all bits are zero:
![Page 28: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/28.jpg)
28
Smallest value for a binary #• The smallest value for a binary number with any number of bits is
zero (i.e. when all the bits are zeros)
# of bits smallest binary # decimal value
1 bit: 0 02 bits: 00 03 bits: 000 04 bits: 0000 05 bits: 00000 06 bits: 000000 07 bits: 0000000 08 bits: 00000000 0etc.
![Page 29: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/29.jpg)
29
Largest value for a binary #
• The largest value for a binary number with a specific number of bits (i.e. digits) is when all of the bits are one.
• General rule: for a binary number with n bits, the largest possible value is : 2n - 1
![Page 30: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/30.jpg)
30
Largest numbers• The following are the largest values for binary numbers with a
specific number of bits:
# of bits largest binary # decimal value
1 bit: 1 12 bits: 11 33 bits: 111 74 bits: 1111 155 bits: 11111 316 bits: 111111 637 bits: 1111111 1278 bits: 11111111 255etc.
![Page 31: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/31.jpg)
31
Converting a decimal# to a binary# (1)• Step 1: figure out how many bits you will need
(see the chart on the previous slide).
– Example 1: To convert the decimal number 16 to binary, you will need at least 5 bits. (With 4 bits you can only store numbers up to 15 but with 5 bits you can store numbers up to 31)
– Example 2: To convert the decimal number 106 to binary, you will need at least 7 bits. (With 6 bits you can only store numbers up to 63 but with 7 bits you can store numbers up to 127)
![Page 32: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/32.jpg)
32
Converting a decimal# to a binary# (2)• Step 2: Keep a chart of the position values and the digits
for your binary number. At first you will not know what any of the digits will be.
• Example: convert decimal 106 to binary– step 1 : figure out that you need 7 bits (see earlier slides)– step 2 : keep track of position values and bits for binary #
64 32 16 8 4 2 1--------------------------------------------------------------------------------
? ? ? ? ? ? ?
![Page 33: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/33.jpg)
33
Converting a decimal # to binary (3)• Step 3: starting with the leftmost digit, see if the position value
is greater than, less than or equal to the number you are trying to convert.
– if the position value is greater than the number then• make the binary digit in that position zero
– if the position value is less than the number then • make the binary digit in that position one• subtract the position value from the decimal # you are trying to convert
– if the position value is equal to the number then • make the binary digit in that position one• make the rest of the binary digits zero• you are done
![Page 34: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/34.jpg)
34
Converting a decimal # to binary (4)
• Step 4: do step 3 again with the next digit. Keep doing this until you've figured out all of the digits.
![Page 35: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/35.jpg)
35
Example• Example: convert decimal 106 to binary
– Step 1: You need 7 bits (see earlier slides for explination).– Step 2: keep track of position values for bits
64 32 16 8 4 2 1--------------------------------------------------------------------------------? ? ? ? ? ? ?
– Step 3: Check leftmost position value (i.e. 64)• 64 is less than 105, therefore• the first binary digit is 1
64 32 16 8 4 2 1--------------------------------------------------------------------------------1 ? ? ? ? ? ?
• subtract : 106 - 64 = 42
![Page 36: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/36.jpg)
36
Example (continued-2)– Step 4: Check next position value (i.e. 32)
• 32 is less than 42, therefore• the next binary digit is 1
64 32 16 8 4 2 1-------------------------------------------------------------------------------
1 1 ? ? ? ? ?• subtract : 42 - 32 = 10
– Step 4(continued): Check next position value (i.e. 16)• 16 is greater than 10, therefore• the next binary digit is 0
64 32 16 8 4 2 1-------------------------------------------------------------------------------
1 1 0 ? ? ? ?
![Page 37: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/37.jpg)
37
Example (continued-3)– Step 4(continued): Check next position value (i.e. 8)
• 8 is less than 10, therefore• the next binary digit is 1
64 32 16 8 4 2 1-------------------------------------------------------------------------------
1 1 0 1 ? ? ?• subtract : 10 - 8 = 2
– Step 4(continued): Check next position value (i.e. 4)• 4 is greater than 2, therefore• the next binary digit is 0
64 32 16 8 4 2 1-------------------------------------------------------------------------------
1 1 0 1 0 ? ?
![Page 38: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/38.jpg)
38
Example (continued-4)– Step 4(continued): Check next position value (i.e. 2)
• 2 is equal to 2, therefore• the next binary digit is 1
64 32 16 8 4 2 1-------------------------------------------------------------------------------
1 1 0 1 0 1 ?
• Since the position value was equal to the number (i.e. 2) the rest of the binary digits are all zeros
64 32 16 8 4 2 1---------------------------------------------------------------------------
1 1 0 1 0 1 0
– Answer: 1101010
![Page 39: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/39.jpg)
39
Why is it called "binary" (or base-2)?
• The prefix "bi" means "two" in Latin
• Binary derives its name from the fact that the digits in a "Binary" number can only have two possible values, 0 or 1
• It is also called "base-2" based on the fact that the column values are the powers of 2. (i.e. 20 21 22 23 24 25 etc. )
![Page 40: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/40.jpg)
Hexadecimal (AKA “Hex”) numbers
![Page 41: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/41.jpg)
41
What is a hexadecimal or base-16 number.
• A “hexadecimal” number is a number where each digit may be one of sixteen possible values.
• The possible values for a hexadecimal digit are:0 1 2 3 4 5 6 7 8 9 A B C D E F
• A digit of “A” stands for the number 10“B” stands for the number 11 “C” stands for the number 12 “D” stands for the number 13 “E” stands for the number 14 “F” stands for the number 15
• Keep reading …
![Page 42: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/42.jpg)
Hexadecimal numbers
• The following are all valid hexadecimal nubmers– A– 9 (yes, a hexadecimal number does not HAVE TO contain letters)
– 1001 (yes, a hexadecimal number does not HAVE TO contain letters)
– 9C5
– BFE
– Etc.
• To understand what a specific hexadecimal number means, you can convert it into an equivalent decimal number. (see next slide)
42
![Page 43: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/43.jpg)
Converting a Hexadecimal number to Decimal
• The value of hexadecimal A12F is decimal 41,263. See below:
4096 (i.e 163) 256 (i.e 162) 16 (i.e 161) 1 (i.e 160)----------------------------------------------------------------------
A 1 2 F15 X 1= 15
2 X 16 = 321 X 256 = 256
10 X 4096 = 40,960----
Answer: 41,263
43
![Page 44: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/44.jpg)
Hex numbers are a “shorthand” for binary nubmers
• It is very easy to convert between Hex and binary numbers.
• Each Hex number is 1/4th the length of its equivalent binary number.
• Therefore Hex is often used as a “shorthand” for writing an equivalent binary number.
• Keep reading …
44
![Page 45: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/45.jpg)
The numbers from decimal 0 through 15 in hex and binary
• Draw a table here with appropriate info.
45
![Page 46: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/46.jpg)
Converting from Hex to Binary46
![Page 47: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/47.jpg)
Converting from Binary to Hex47
![Page 48: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/48.jpg)
How a computer stores information (i.e. decimal vs. analog)
![Page 49: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/49.jpg)
49
How a computer stores info.
• A computer stores all information as binary numbers.
• Computer memory simply remembers ones and zeros
• Computer storage remembers ones and zeros
• Data is passed inside the computer from one portion of the computer to another (e.g. memory to CPU to graphics card, etc) by ones and zeros
![Page 50: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/50.jpg)
50
Terms (bit, byte, etc)
• BIT– definition: a single Binary digIT (i.e. BIT)
• BYTE– definition: 8 bits
• NYBLE– definition: 4 bits
![Page 51: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/51.jpg)
51
Prefixes
• Prefixes– Kilo: one thousand– Mega: one millioin– Giga: one billion– Tera: one trillion– Peta: one quadrillion– Exa: one quintillion – … etc.
![Page 52: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/52.jpg)
52
Data sizes• Data sizes
– Kilobyte (KB)• "about" one thousand bytes • exactly 210 or 1024 bytes
– Megabyte (MB)• "about" one million bytes• exactly 220 or 1,048,576 bytes
– Gigabyte (GB)• "about" one billion bytes • exactly 230 or 1,073,741,824 bytes
– Terabyte (TB)• "about" one trillion bytes • exactly 240 or 1,099,511,627,776 bytes
![Page 53: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/53.jpg)
53
Data Sizes – bytes vs bits
• MB = one Mega Byte
• Mb = one Mega Bit
![Page 54: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/54.jpg)
54
Speeds
• MBPS = one MegaByte per second
• MbPS = one Mega Bit per second
![Page 55: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/55.jpg)
55
How data is stored using binary
• Integers are stored as a binary number
• A character is stored as the ASCII value (i.e. an integer) for that character
• A decimal number is stored using two different integer values - the mantissa and the exponent
![Page 56: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/56.jpg)
56
Organization of Computer Memory
![Page 57: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/57.jpg)
57
CPU
![Page 58: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/58.jpg)
58
Passing information on wires
![Page 59: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/59.jpg)
59
![Page 60: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/60.jpg)
Hexadecimal - a shorthand for binary
![Page 61: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/61.jpg)
61
Hexadecimal ("Hex") / Base-16
• Base 16• Uses digits:
– 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
• A - F– a is 10
– b is 11
– c is 12
– d is 13
– e is 14
– f is 15
![Page 62: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/62.jpg)
62
Converting from Hex to Decimal
![Page 63: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/63.jpg)
63
Converting from Decimal to Hex
![Page 64: Binary and Decimal Numbers Prof. Rosenthal. 2 What is a binary number? A binary number is a number that includes only ones and zeroes. The number could](https://reader035.vdocuments.us/reader035/viewer/2022062221/56649d965503460f94a8004c/html5/thumbnails/64.jpg)
64
Applications
• HTML : color codes
• Shorthand for binary– See hex editor