Today s topics! Binary Numbers! Brookshear.-.! Slides from Prof. Marti Hearst of UC Berkeley SIMS! Upcoming! Networks Interactive Introduction to Graph Theory http://www.utm.edu/cgi-bin/caldwell/tutor/departments/math/graph/intro Kearns, Michael. "Economics, Computer Science, and Policy." Issues in Science and Technology, Winter 5.! Problem Solving Digital Computers! What are computers made up of?! Lowest level of abstraction: atoms! Higher level: transistors! Transistors! Invented in 95 at Bell Labs! An electronic switch! Building block for all modern electronics! Transistors are packaged as Integrated Circuits (ICs)! million transistors in IC Compsci. Compsci. Binary Digits (Bits)! Yes or No! On or Off! One or Zero! More on binary! Byte! A sequence of bits! 8 bits = byte! bytes = word (sometimes or 8 bytes)! Powers of two! How do binary numbers work? Compsci. Compsci.
Data Encoding! Text: Each character (letter, punctuation, etc.) is assigned a unique bit pattern.! ASCII: Uses patterns of 7-bits to represent most symbols used in written English text! Unicode: Uses patterns of -bits to represent the major symbols used in languages world side! ISO standard: Uses patterns of -bits to represent most symbols used in languages world wide! Numbers: Uses bits to represent a number in base two! Limitations of computer representations of numeric values! Overflow happens when a value is too big to be represented! Truncation happens when a value is between two representable values Images, Sound, & Compression! Images! Store as bit map: define each pixel RGB Luminance and chrominance! Vector techniques Scalable TrueType and PostScript! Audio! Sampling! Compression! Lossless: Huffman, LZW, GIF! Lossy: JPEG, MPEG, MP Compsci.5 Compsci. Decimal (Base ) Numbers Binary (Base ) Numbers! Each digit in a decimal number is chosen from ten symbols: {,,,,, 5,, 7, 8, 9 }! The position (right to left) of each digit represents a power of ten.! Example: Consider the decimal number 7 7!!!! position: 7 = " + " + " + 7"! Each digit in a binary number is chosen from two symbols: {, }! The position (right to left) of each digit represents a power of two.! Example: Convert binary number to decimal!!!! position: = " + " + " + " = "8 + " + " + " = 8 + + = Compsci.7 Compsci.8
Powers of Two Famous Powers of Two Decimal 8 8 Binary Power of 5 7 Compsci.9 Compsci. Other Number Systems Binary Addition Also: + + = with a carry of Compsci. Compsci.
Adding Binary Numbers + --------! + = ( " + " + " ) + ( " + " ) = ( " + " + " ) + ( " + " )! Add like terms: There is one, one, one = " + " + " = Adding Binary Numbers $ carry + ---------! + = ( " + " + " ) + (" + " + " ) = ( " + " + " ) + (" + " + " )! Add like terms: There are two s, two s, one = " + " + "! BinaryNumber Applet = "8 + " + " + " = Compsci. Compsci. Converting Decimal to Binary Converting Decimal to Binary Decimal 5 7 8 # # conversion # # = " = " = " + " = + = " + " = " + " + " 5 = + = " + " + " = + = " + " + " 7 = ++ = " + " + " 8 = " + " + " + " Binary! Repeated division by two until the quotient is zero! Example: Convert decimal number 5 to binary 7 Binary representation of 5 is 5 remainder Compsci.5 Compsci.
Converting Decimal to Binary Problems 7 5! Subtracting highest power of two! s in positions 5,,,! = plus thirty-two! 8s = plus sixteen! s = plus eights! s = 8s plus four! 7 s = s plus two! 5 = 7 s plus ones 5-5 = - = - = - = Compsci.7! Convert to decimal representation! Add the binary numbers and and express their sum in binary representation! Convert 77 to binary representation Compsci.8 Solutions! Convert to decimal representation Solutions! Convert 77 to binary representation = " + " 5 + " + " + " + " + " = " + " + " + "8 + " + " + " = + + 8 = 88! Add the binary numbers and and express their sum in binary representation + ------------- 9 9 8 77 Binary representation of 77 is Compsci.9 Compsci.
Boolean Logic! AND, OR, NOT, NOR, NAND, XOR! Each operator has a set of rules for combining two binary inputs! These rules are defined in a Truth Table! (This term is from the field of Logic)! Each implemented in an electronic device called a gate! Gates operate on inputs of s and s! These are more basic than operations like addition! Gates are used to build up circuits that Compute addition, subtraction, etc Store values to be used later Translate values from one format to another Truth Tables Compsci. Compsci. In-Class Questions. How many different bit patterns can be formed if each must consist of exactly bits?. Represent the bit pattern in hexadecimal notation.. Translate each of the following binary representations into its equivalent base ten representation..... Translate in decimal to binary Compsci.