Download presentation
Presentation is loading. Please wait.
1
CSE111: Great Ideas in Computer Science Dr. Carl Alphonce 219 Bell Hall Office hours: M-F 11:00-11:50 645-4739 alphonce@buffalo.edu
2
Announcements No recitations this week. First meeting of recitations in week of 1/25-1/29. Extra copies of syllabus available at course web-site (address is on UB Learns). 2
3
cell phones off (please) 3
4
Agenda Review from last class –same data, different encodings Today’s topics –binary numbers 4
5
Review Color encoding –RBG vs. CMYK encodings Number encoding –base 10 vs. base 2 Same information can be encoded in many different ways. 5
6
Counting Decimal (base 10) 0 1 2 3 4 5 6 7 8 9 10 11 12 13 etc. Binary (base 2) 0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 etc. 6
7
Number systems Decimal (base 10) Each position is weighted by a power of 10. E.g. 734 = –7*100 + 3*10 + 4*1 –7*10 2 + 3*10 1 + 4*10 0 E.g. 1101 = –1*1000 + 1*100 + 0*10 + 1*1 –1*10 3 + 1*10 2 + 0*10 1 + 1*10 0 Binary (base 2) Each position is weighted by a power of 2. E.g. 111 = –1*4 + 1*2 + 1*1 = “seven” –1*2 2 + 1*2 1 + 1*2 0 E.g. 1101 = –1*8 + 1*4 + 0*2 + 1*1 = “thirteen” –1*2 3 + 1*2 2 + 0*2 1 + 1*2 0 7
8
Bit string A ‘0’ or ‘1’ is a binary digit, or a bit. A sequence of bits is called a bit string. For example: –00001101 is a bit string As numbers: ‘0’ is zero, ‘1’ is one Reality –just two symbols –In hardware: two different voltage levels 8
9
Binary Arithmetic Operations in base 2 work the same as in base 10. Addition: 2 + 3 = 5 10 +11 101 9
10
Exercises Compute the following sums, in base 2 5 + 1 = 68 + 8 = 1610 + 12 = 22 10
11
Setting up the exercises Compute the following sums, in base 2 5 + 1 = 68 + 8 = 1610 + 12 = 22 101 1000 1010 + 001 + 1000 + 1100 11
12
Solving up the exercises Compute the following sums, in base 2 5 + 1 = 68 + 8 = 1610 + 12 = 22 101 1000 1010 + 001 + 1000 + 1100 110 10000 10110 12
13
Interpretation QUESTION: –What does 1101 represent? 13
14
Interpretation QUESTION: –What does 1101 represent? ANSWER: –Whatever we want it to represent! 14
15
Encoding Schemes RGB / CMYK (colors) Binary (non-negative numbers) Two’s complement (integers) IEEE 754 (approx. floating point numbers) ASCII / EBCDIC / Unicode (characters) GIF / BMP / JPG (images) MP3 / CD (audio) MPEG-2 / MPEG-4 (video – e.g. BluRay and HDTV) 15
16
Fixed-width encodings Suppose we have a four-bit wide representation. We then have 2 4 = 2*2*2*2 = 16 distinct bit patterns: 16 00001000 00011001 00101010 00111011 01001100 01011101 01101110 01111111
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.