1 CS151 Introduction to Digital Design Chapter 1 Lecture 3
CS Octal to Binary and Back Octal to Binary: Restate the octal as three binary digits starting at the radix point and going both ways. Binary to Octal : Group the binary digits into three bit groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part. Convert each group of three bits to an octal digit.
CS Hexadecimal to Binary and Back Hexadecimal to Binary: Restate the hexadecimal as four binary digits starting at the radix point and going both ways. Binary to Hexadecimal: Group the binary digits into four bit groups starting at the radix point and going both ways, padding with zeros as needed in the fractional part. Convert each group of three bits to a hexadecimal digit.
CS Octal to Hexadecimal via Binary Convert octal to binary. Use groups of four bits and convert as above to hexadecimal digits. Example: Octal to Binary to Hexadecimal Why do these conversions work? Answer in notes page for this slide…
CS Conversion Between Bases Method 2 To convert from one base to another: 1) Convert the Integer Part 2) Convert the Fraction Part 3) Join the two results with a radix point
CS Conversion Details To Convert the Integer Part: Repeatedly divide the number by the new radix and save the remainders. The digits for the new radix are the remainders in reverse order of their computation. If the new radix is > 10, then convert all remainders > 10 to digits A, B, … To Convert the Fractional Part: Repeatedly multiply the fraction by the new radix and save the integer digits that result. The digits for the new radix are the integer digits in order of their computation. If the new radix is > 10, then convert all integers > 10 to digits A, B, …
CS Example: Convert To Base 2 1. Convert 46 to Base 2 2. Convert to Base 2: 3. Join the results together with the radix point: Answer in notes page for this slide…
CS Additional Issue - Fractional Part Note that in this conversion, the fractional part became 0 as a result of the repeated multiplications. In general, it may take many bits to get this to happen or it may never happen. Example: Convert to N 2 0.65 = … The fractional part begins repeating every 4 steps yielding repeating 1001 forever! Solution: Specify number of bits to right of radix point and round or truncate to this number.
CS Checking the Conversion To convert back, sum the digits times their respective powers of r. From the prior conversion of = 1*32 + 0*16 +1*8 +1*4 + 1*2 +0*1 = = = 1/2 + 1/8 + 1/16 = =
CS Number Ranges 624 Consider a 3-digit counter. What is the minimum number it can show? What is the maximum number it can show? What is it’s number range? position Each position has 10 possibilities: 0,1,2,3,4,5,6,7,8,9. 10 * 10 * 10 = 10 3 Radix # Positions Range: 0 ( )
CS Number Ranges 010 What if the counter was a 3-bit binary counter? What is the minimum number it can show? What is the maximum number it can show? What is it’s number range? position Each position has 2 possibilities: 0,1. 2 * 2 * 2 = 2 3 Radix # positions (bits) (000) 2 (111) 2 = 7 10 Range: 0 7 0 (2 3 -1)
CS Given n digits in radix r, there are r n distinct elements that can be represented. These elements range from 0 to r n -1 Number Ranges BONUS: What is the minimum number of bits, n, needed to represent a binary code of M elements ???
CS Number Ranges Range of numbers is based on the number of bits available in the hardware structure that store and process information. (E.g. registers). Usually, size of these structures is a power of 2. (8 bits, 16 bits, 32 bits, 64 bits and 128 bits).
CS Binary Arithmetic Single Bit Addition with Carry Multiple Bit Addition Single Bit Subtraction with Borrow Multiple Bit Subtraction Multiplication BCD Addition When working with base-r, use ONLY r allowable digits (0..r-1) and perform all computations with base r digits.
CS Single Bit Binary Addition with Carry Z X Y C S Z X Y C S
CS Extending this to two multiple bit examples: Carries 0 0 Augend Addend Sum Note: The 0 is the default Carry-In to the least significant bit. Multiple Bit Binary Addition Kindly view notes page for answer.
CS Given two binary digits (X,Y), a borrow in (Z) we get the following difference (S) and borrow (B): Borrow in (Z) of 0: Borrow in (Z) of 1: Single Bit Binary Subtraction with Borrow Z X Y BS Z X Y BS
CS Extending this to two multiple bit examples: Borrows 0 0 Minuend Subtrahend Difference Notes: The 0 is a Borrow-In to the least significant bit. If the Subtrahend > the Minuend, interchange and append a – to the result. Multiple Bit Binary Subtraction Kindly view notes page for answer.
CS Binary SubtractionBorrows: Minuend:10011 Subtrahend: Difference: Swap Multiple Bit Binary Subtraction
CS Binary Multiplication +
CS Octal Multiplication Multiplicand:762 Multiplier: x Product: OctalDecimalOctal 5x2 =10= x6 +1=31= x7 +3=38= x2=8 = x6 +1=25= x7 +3=31= Form a table to calculate sums and products of 2 digits in base-r (in this case, base-8)
CS Hexadecimal Addition HexDecimal +++ Carry =16+ 5 Carry 1 14 = E19 = E 51 3 E F E 4 6 +