DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR

Size: px
Start display at page:

Download "DLD VIDYA SAGAR P. potharajuvidyasagar.wordpress.com. Vignana Bharathi Institute of Technology UNIT 1 DLD P VIDYA SAGAR"

Transcription

1 UNIT I Digital Systems: Binary Numbers, Octal, Hexa Decimal and other base numbers, Number base conversions, complements, signed binary numbers, Floating point number representation, binary codes, error detecting and correcting codes, digital logic gates(and, NAND,OR,NOR, Ex-OR, Ex-NOR), Boolean algebra, basic theorems and properties, Boolean functions, canonical and standard forms. DLD VIDYA SAGAR P

2 Number Systems : A number system is a representation method for numbers, A number system is identified by its base,the base is a decimal unsigned integer with a minimum value of 2,The is no limit on the maximum value for the base, however, the largest known base is 16,Commonly used number systems are also identified by their name There are 4 commonly used number systems: Decimal base 10 Hexadecimal base 16 Octal base 8 Binary base 2 The base determines the range of a digit in the number system which starts with 0 and ends with base-1 For bases with range exceeding 10, the A-Z alpha symbols are used to represent values greater than 9 Examples Base 10 digit range is 0 9 Base 5 digit range is 0-4 Base 16 digit range is 0 9 and A F Computers internally stores and process data using the binary system Binary is compatible with the computer hardware architecture which is based on Boolean digital logic Binary is base 2 with a digit range of 0-1 A binary digit is also known as bit Most computers use the hexadecimal or the octal number systems in programming and debugging Hexadecimal is also known as hex Hex is base 16 with a digit range of 0 9, A F Octal is base 8 with a digit range of 0 7 Advantages Both number systems can be used as a short hand notation for binary More readable than binary and hence easier for humans to work with Easy to convert into and from binary Humans on the other hand, work with the decimal system, Conversion between binary and decimal is necessary to make human to machine interaction possible, Conversion between the different number systems is also possible, Conversion does not change the magnitude of the number

3 Counting in Different Bases : Counting is the process of repeatedly adding 1 to the number Going through a complete digit range, exhausting all possible combinations Shift to the left one place Repeat as necessary until the number is completely represented Theoretically, the counting process can continue indefinitely, However, there is always a limit on the available digits to store a number (storage size),therefore, counting process will stop when all the available digits are exhausted, Overflow will occur when storage size limit is exceeded The following table shows a count in hexadecimal, decimal, octal, and binary Hexadecimal Decimal Octal Binary A B C D E F Range Calculations : The range of a number that can be represented is determined by: Storage size number of digits Base of the number system used to represent the number Range can be computed as: (result in decimal) R = B n (R = Range, B = Base, n = number of digits)

4 Examples: 8 binary bits range 2 8 = decimal digits range 10 3 = digits in hex range 16 3 = Binary range calculations is often required in computers Examples : Integer number data unit range with storage size of 16 bits = 2 16 = Memory addressing capability MAR size of 32 bits = 2 32 = 4GB Range can also be computed as the product of its sub-ranges 32 binary bits range 2 10 X 2 10 X 2 10 X 2 2 = 1K X 1K X 1K X 4 = 4G 12 binary bits range 2 10 X 2 2 = 1K X 4 = 4K Integer Digit Weight Calculations : A digit weight is computed as: (result is always in decimal) W = B n (W = Weight, B = base, n = digit position) Digit position numbering starts from the least significant digit and ends with the most significant digit Digit position starts at 0 and ends with the number of digits 1 Examples: 4-digit decimal weight calculation 10 3, 10 2, 10 1, 10 0 = , , 10 10, bit binary weight calculation 2 3, 2 2, 2 1, 2 0 = 8 10, 4 10, 2 10, digit octal weight calculation 8 3, 8 2, 8 1, 8 0 = , 64 10, 8 10, 1 10 Note: that any base power 0 = 1 Each digit has n times the weight of its next rightmost neighbor (where n is the base) In binary each digit has twice the weight of its next right neighbor In decimal each digit has 10 times the weight of its next rightmost neighbor Convert between related bases : Two number systems are related when one number system base is an integral power of the other A single digit in the larger base requires n digits in the smaller base (where n is the power value) Octal is related to binary since it takes 3 binary digits to represent 1 octal digit (2 3 = 8) Hex is related to binary since it takes 4 binary digits to represent 1 hex digit (2 4 = 16) Hex and octal, however, are not related Conversion between related number systems is direct Use a trial and error method to determine if two bases are related Smaller base power 2, 3, 4, and so on If result = larger base, then the two bases are related If result exceed larger base, then the two bases are not related

5 Examples : 1. Are 2 and 16 related? 2 2 = = = 16 base 2 and 16 are related 2. Are 3 and 8 related? 3 2 = 9 base 3 and 8 are not related Smaller base to larger base conversion method : Determine the n value Construct a conversion table (i.e. counting table as seen above is an example of conversion table) Group the number into groups of n digits Must start grouping from the right (i.e. least significant digit) Pad with zeros if last group is less than n digits Group by group, perform direct conversion using the conversion table Examples : Convert to hex 4 binary digits are required to represent a single hex digit (i.e. n = 4) Refer to the conversion table above Group the number into groups of 4 digits: Pad last group with zeros: Convert each group to their equivalent hex digit = 35D8 16 Convert to octal 3 binary digits are required to represent a single octal digit (i.e. n = 3) Refer to the conversion table above Group the number into groups of 3 digits: Pad last group with zeros: Convert each group to their equivalent octal digit = Convert to base 4 2 binary digits are required to represent a single base 4 digit (i.e. n = 2) Construct a conversion table Base 4 Binary Group the number into groups of 2 digits: Convert each group to their equivalent hex digit =

6 Larger base to Smaller base conversion : Determine the n value Construct a conversion table (i.e. counting table as seen above) Digit by digit, perform direct conversion using the conversion table Notes: don t miss padding leading zeros to fill the n digits in the smaller base Examples Convert 35D8 16 to binary Each hex digit requires 4 binary digits (i.e. n = 4) Refer to the conversion table above Map each digit to its equivalent binary digits Convert to binary = Each octal digit requires 3 binary digits (i.e. n = 3) Refer to the conversion table above Map each digit to its equivalent binary digits Convert to binary = Each base 4 digit requires 2 binary digits (i.e. n = 2) Refer to the base 4 to binary conversion table above Map each digit to its equivalent binary digits = Convert between non decimal and non related number systems : It is impractical to directly convert between none decimal number systems that are not related Decimal can be used as an intermediary conversion base As well, a base that is related to both bases can be used as an intermediary conversion base Binary can be used as an intermediate conversion base to convert between hex and octal Examples : Convert 35D8 16 to octal (note that the two bases are none decimal and are not related) Convert the number to binary = Convert the binary result to octal = = Convert to base 5 (note that the two bases are none decimal and are not related) There is no intermediate base that is related to both bases so we use decimal as an intermediate base

7 Convert the number to decimal = 0 x x x x 3 3 = Convert the decimal result to base 5 = Fraction conversion: = Fraction number conversion does not always result in an accurate result due to: Representation of a fraction number that is possible in one base may be impossible to represent in another base If precise conversion cannot be done, conversion will result in lose of accuracy (i.e. lose of significant digits) Examples: is impossible to represent in binary ( ) is impossible to represent in decimal ( ) When converting a number that contains both integer and fraction parts The two parts must be converted separately The fraction point must remain at its original location Number base conversions: Decimal to any base conversion Steps : Step 1 Divide the decimal number to be converted by the value of the new base. Step 2 Get the remainder from Step 1 as the rightmost digit (Least Significant Digit) of new base number. Step 3 Divide the quotient of the previous divide by the new base. Step 4 Record the remainder from Step 3 as the next digit (to the left) of the new base number. Repeat Steps 3 and 4, getting remainders from right to left, until the quotient becomes zero in Step 3. The last remainder thus obtained will be the Most Significant Digit (MSD) of the new base number. Examples: Decimal to Binary: Two methods: There are reverse processes of the two methods used to convert a binary no. to a decimal no. I method: is for small no s The values of various powers of 2 need to be remembered for conversion of larger no s have a table of powers of 2 known as the sum of weights method. The set of binary weight values whose sum is equal to the decimal no. is determined. To convert a given decimal integer no. to binary, (1). Obtain largest decimal no. which is power of 2 not exceeding the remainder & record it (2). Subtract this no. from the given no & obtain the remainder

8 (3). Once again obtain largest decimal no. which is power of 2 not exceeding this remainder & record it. (4). Subtract through no. from the remainder to obtain the next remainder. (5). Repeat till you get a 0 remainder The sum of these powers of 2 expressed in binary is the binary equivalent of the original decimal no. similarly to convert fractions to binary. II method: It converts decimal integer no. to binary integer no by successive division by 2 & the decimal fraction is converted to binary fraction by double dabble method. Example: binary Given decimal no. is mixed no.so convert its integer & fraction parts separately. Integer part is The largest no. which is a power of 2, not exceeding 163 is =27 = remainder is =35 The largest no., a power of 2, not exceeding 35 is =2 5 = , Remainder is 35-32=3 The largest no., a power of 2, not exceeding 35is 2. 2=2 1 =102, Remainder is 3-2=1 1=2 0 = = = The fraction part is The largest fraction, which is a power of 2, not exceeding is =2-1 =0.1002, Remainder is = is =2-2 =0.012, Remainder is = is itself =2-3 = = = Final result is = Here is an example of using double dabble method to convert 1792 decimal to binary: Decimal NumberOperationQuotientRemainderBinary Result = = = = = = = = = = = done.

9 Decimal to Octal Here is an example of using repeated division to convert 1792 decimal to octal: Decimal NumberOperationQuotientRemainderOctal Result = = = = done. Decimal to Hexadecimal Here is an example of using repeated division to convert 1792 decimal to hexadecimal: Decimal Number Operation Quotient Remainder Hexadecimal Result = = = done. The only addition to the algorithm when converting from decimal to hexadecimal is that a table must be used to obtain the hexadecimal digit if the remainder is greater than decimal 9. Decimal: Hexadecimal: A B C D E F The addition of letters can make for funny hexadecimal values. For example, decimal converted to hex is: Decimal Number Operation Quotient Remainder Hexadecimal Result = F = EF = EEF = 0 11 BEEF 0 done. MORE EXAMPLES: Convert to base 5 New Base From Base Number Remainder least significant digit most significant digit 0 =

10 Convert to hexadecimal New Base From Base Number Remainder least significant digit most significant digit 0 = 1FD7 16 Convert to binary New Base From Base Number Remainder least significant digit most significant digit 0 = Binary to any base conversion Steps: Binary to Decimal: A method to convert from binary to decimal. This method involves addition and multiplication. 1. Start the decimal result at Remove the most significant binary digit (leftmost) and add it to the result. 3. If all binary digits have been removed, you re done. Stop. 4. Otherwise, multiply the result by Go to step 2. Here is an example of converting binary to decimal: Binary Digits Operation Decimal Result Operation Decimal Result Done.

11 Binary to Octal: An easy way to convert from binary to octal is to group binary digits into sets of three, starting with the least significant (rightmost) digits. Binary: = Then, look up each group in a table: Pad the most significant digits with zeros if necessary to complete a group of three. Binary: Octal: Binary = Octal = = 345 oct Binary to Hexadecimal: An equally easy way to convert from binary to hexadecimal is to group binary digits into sets of four, starting with the least significant (rightmost) digits. Binary: Hexadecimal: Binary: Hexadecimal: 8 9 A B C D E F Binary: = Then, look up each group in a table: Binary = Hexadecimal = E 5 = E5 hex Octal to any base conversion Steps: Octal to Binary: Converting from octal to binary is as easy as converting from binary to octal. Simply look up each octal digit to obtain the equivalent group of three binary digits. Octal: Binary: Octal = Binary = = binary Octal to Hexadecimal : When converting from octal to hexadecimal, it is often easier to first convert the octal number into binary and then from binary into hexadecimal. For example, to convert 345 octal into hex: (from the previous example) Octal = Binary = = binary

12 Drop any leading zeros or pad with leading zeros to get groups of four binary digits (bits): Binary = Then, look up the groups in a table to convert to hexadecimal digits. Binary: Hexadecimal: Binary: Hexadecimal: 8 9 A B C D E F Binary = Hexadecimal = E 5 = E5 hex Therefore, through a two-step conversion process, octal 345 equals binary equals hexadecimal E5. Octal to Decimal : Converting octal to decimal can be done with repeated division. 1. Start the decimal result at Remove the most significant octal digit (leftmost) and add it to the result. 3. If all octal digits have been removed, you re done. Stop. 4. Otherwise, multiply the result by Go to step 2. Octal Digits Operation Decimal Result Operation Decimal Result Done. The conversion can also be performed in the conventional mathematical way, by showing each digit place as an increasing power of octal = (3 * 8 2 ) + (4 * 8 1 ) + (5 * 8 0 ) = (3 * 64) + (4 * 8) + (5 * 1) = 229 decimal. Hexadecimal to any base conversion Steps: Hexadecimal to Binary : Converting from hexadecimal to binary is as easy as converting from binary to hexadecimal. Simply look up each hexadecimal digit to obtain the equivalent group of four binary digits. Hexadecimal: Binary: Hexadecimal: 8 9 A B C D E F Binary: Hexadecimal = A 2 D E Binary = = binary

13 Hexadecimal to Octal : When converting from hexadecimal to octal, it is often easier to first convert the hexadecimal number into binary and then from binary into octal. For example, to convert A2DE hex into octal: (from the previous example) Hexadecimal = A 2 D E Binary = = binary Add leading zeros or remove leading zeros to group into sets of three binary digits. Binary: = Then, look up each group in a table: Binary: Octal: Binary = Octal = = octal Therefore, through a two-step conversion process, hexadecimal A2DE equals binary equals octal Hexadecimal to Decimal : Converting hexadecimal to decimal can be performed in the conventional mathematical way, by showing each digit place as an increasing power of 16. Of course, hexadecimal letter values need to be converted to decimal values before performing the math. Hexadecimal: A B C D E F Decimal: A2DE hexadecimal: = ((A) * 16 3 ) + (2 * 16 2 ) + ((D) * 16 1 ) + ((E) * 16 0 ) = (10 * 16 3 ) + (2 * 16 2 ) + (13 * 16 1 ) + (14 * 16 0 ) = (10 * 4096) + (2 * 256) + (13 * 16) + (14 * 1) = = decimal Signed Number Representation: In general, we represent the positive (unsigned) numbers without any sign indication and negative numbers with minus (negative sign) sign before them. But these are not applicable for computing in the digital systems like, computers, as the data is represented in binary number system. So to represent the sign a special notation is required. Positive Signed binary numbers The binary numbers having their MSB 0 are called Positive signed binary numbers.

14 Negative Signed binary numbers The binary numbers having their MSB 1 are called Negative signed binary numbers. Unsigned numbers can have a wide range of representation. But whereas, in case of signed numbers, we can represent their range only from (2 (n-1) 1) to + (2 (n-1) 1). Where n is the number of bits (including sign bit). Ex: For a 5 bit signed binary number (including 4 magnitude bits & 1 sign bit), the range will be (2 (5-1) 1) to + (2 (5-1) 1) -(2 (4) 1 ) to + (2 (4) 1) -15 to +15 Unsigned 8- bit binary numbers will have range from The 8 bit signed binary number will have maximum and minimum values as shown below. The maximum positive number is The maximum negative number is There are 2 different methods used to represent signed integer in computers Sign-and-magnitude representation Complementary representation Sign-and-magnitude Representation 8-bit sign-magnitude format Sign Magnitude The sign is represented followed by the number magnitude A sign bit, typically the leftmost bit, (0 for +, 1 for -) is used to represent the sign The positive range is one-half of the range and the negative range is makes up the second half Example: 16-bit (1 bit sign and 15 bit magnitude) have a positive range of: +0 to and negative range of and -0 to Note that the total range is the same but redistributed between the positive side and the negative side Disadvantage There are 2 different values for the zero (i.e. +0 and 0) The system must test at the end of every calculation to ensure the presence of a single 0,Calculations is very complex and difficult to implement in hardware (i.e. no consistent way of performing the calculations)

15 Complementary Representation: Complementary representation is the prevalent method for representing signed integer in computers. Every number system has 2 forms of complementary representations Base (R-1) s complement Base R s complement 2 forms of binary complementary representation 1 s complement 2 s complement 2 forms of decimal complementary representation 9 s complement 10 s complement 2 forms of hex complementary representation 15 s complement 16 s complement 2 forms of octal complementary representation 7 s complement 8 s complement

16 Advantage Provide sign free representation The sign of the number does not need special handling Calculations is simple and consistent for all different signed combination of numbers For simplicity let s first start by studying the decimal complementary representation: 9 s complement 10 s complement 9 s Complement Representation 9 s complement is the decimal counter part of the binary 1 s complement Positive range matches the sign-and-magnitude representation positive range Negative range is different than the sign-and-magnitude representation negative range The sign of a number is determined by checking the most significant digit Positive when most significant digit values 0-4 Negative when most significant digit values 5-9 Convert from sign-and-magnitude to 9 s complement Must specify the number of 9 s complement storage digits available to represent the number If number is positive no conversion is necessary (i.e. same as sign-and-magnitude representation) Pad the number with 0 s, if needed, to represent all the assigned number of storage digits If number is negative conversion is required (complement the number) Complementary base number The complementary base is the highest value in the number supported by the given number of digits Complementary base for: 3 digits = digits = Examples 1. Represent 467 in 3-digit 9 s complement The number is negative so complement the number = = Represent 467 in 4-digit 9 s complement The number is negative so complement the number = = Represent 467 in 3-digit 9 s complement The number is positive so the 9 s complement is the same as the number = Represent 667 in 4-digit 9 s complement The number is positive so the 9 s complement is the same as the number Need to pad with zero to fill the entire storage space = Represent 667 in 3-digit 9 s complement The number cannot be represented with only 3-digits (overflow occur) Maximum positive number the can be represent is 499

17 Convert from 9 s complement to sign-and-magnitude Determine whether the number is positive or negative (inspect the most significant digit) If the number is positive, the sign-and-magnitude equivalent is the same as the 9 s complement If the number is negative, complement the number Complementary base number Add the negative sign Examples 1. Convert 9990 to sign-and-magnitude representation The number is negative (most significant digit is 9) Complement the number: = 9 Add negative sign Convert 595 to sign-and-magnitude representation The number is negative (most significant digit is 5) Complement the number: = 404 Add negative sign = Convert 4990 to sign-and-magnitude representation The number is positive (most significant digit is 4) The result is the same as the 9 s complement = 4990 Addition and Subtraction Arithmetic (9 s complement) Addition in 9 s complement is done using the following method: Add the 2 numbers in the normal way Add 1 to the result if there is end-round carry An end-round carry occur if the result overflow the storage space Subtraction in 9 s complement is done using the following method: Complement any number with negative sign (i.e. eliminate the negative sign) Add the two numbers using the same method as the Addition in 9 s Complement Examples : Add ( ) o = 899 Add ( ) o =(1)099 o Add end-round carry = = 100 Add ( ) o = 1099

18 Subtract ( ) o Find 9 s complement of 100 = = 899 o Add = (1) 698 o Add the end-round carry = = 699 Subtract ( ) o Find 9 s complement of 90 = = 909 o Add = (1)015 o Add end-round carry = = 016 Subtract ( ) o Find 9 s complement of 90 = = 9909 o Add = (1) 0015 o Add end-round carry = = 0016 Subtract (-40-2) o Find 9 s complement of 40 = = 59 o Find 9 s complement of 2 = 99 2 = 97 o Add = (1) 56 o Add end-round carry = = s Complement Representation The 10 s complement solves the dual zero problem in 9 s complement See Figure 4.11 in page 110 for 10 s complement representation of 3-digit decimal number 10 s complement = 9 s complement + 1 Convert from sign-and-magnitude to 10 s complement Similar to 9 s complement with the following differences Complementary base is 1 more than the 9 s complement (i.e. 9 s complement + 1) Examples Represent 467 in 3-digit 10 s complement The number is negative so complement the number = = 533 Represent 467 in 4-digit 10 s complement The number is negative so complement the number = = 9533 Represent 467 in 3-digit 10 s complement The number is positive so the 10 s complement is the same as the number = 467 Represent 667 in 4-digit 10 s complement The number is positive so the 10 s complement is the same as the number = 0667 Represent 667 in 3-digit 10 s complement The number cannot be represented with only 3-digits (overflow)

19 Convert 10 s complement to sign-and-magnitude Similar to 9 s complement with the following differences Complementary base is 1 more than the 9 s complement (i.e. 9 s complement + 1) Examples 1. Convert 9990 to sign-and-magnitude representation The number is negative (most significant digit is 9) Find 10 s complement = = 10 Add negative sign = -10 Convert 595 to sign-and-magnitude representation The number is negative (most significant digit is 5) Complement the number: = 405 Add negative sign = Convert 4990 to sign-and-magnitude representation o The number is positive (most significant digit is 4) o The result is the same as the 10 s complement = 4990 Addition and Subtraction Arithmetic (10 s complement) Addition in 10 s complement is done using the following method: Add the two numbers Carry beyond the specified number of digits is dropped Subtraction in 10 s complement is done using the following method: Find the 10 s complement of any number with negative sign (i.e. eliminate the negative sign) Add using the same method as the Addition in 10 s Complement Examples 1. Add ( ) o = Add ( ) o = (1)099 o Drop the end-round carry = Add ( ) o = Subtract ( ) o Find the 10 s complement of 100 = = 900 o Add = (1) 699 o Drop the end-round carry = Subtract ( ) o Find the 10 s complement of 90 = = 910 o Add = (1) 016; Drop the end-round carry = 016

20 6. Subtract ( ) o Find the 10 s complement of 0090 = = 9910 o Add = (1) 0016 o Drop the end-round carry = s Complement Representation 1 s complement is a complementary representation method for representing signed integer in binary 1 s complement is the counter part of 9 s complement in decimal See Figure 4.10 for illustration of 8-bit 1 s complement representation The sign of a number is determined by checking the most significant bit Positive when most significant bit is 0 Negative when most significant bit is 1 1 s complement is performed by inverting every bit (0 becomes 1 and 1 becomes 0) Find 1 s complement Pad the number with 0 s if needed to represent all the assigned number of storage bits Invert the bits Examples Find the 8-bit 1 s of the binary number Invert to find the 1 s complement = Find the 16-bit 1 s of the binary number Pad with 0 s to get 16-bit representation = Invert to find the 1 s complement = Convert from decimal sign-and-magnitude to 1 s complement Convert the decimal number to binary Pad with zeros to fill the entire storage space Determine whether the number is positive or negative If the number is positive, no need to complement the number If the number is negative, you need to complement the number Examples Convert to 8-bit 1 s complement Convert from decimal to binary = Pad with 0 s to get 8-bit representation = The number is negative (the sign is -) so invert the bits =

21 Convert to 16-bit 1 s complement Convert from decimal to binary = Pad with 0 s to get 16-bit representation = The number is positive so no need to complement = Convert to 16-bit 1 s complement Convert from decimal to binary = Pad with 0 s to get 16-bit representation = The number is negative so invert the bits = Convert from 1 s complement to decimal sign-and-magnitude Determine whether the number is positive or negative If the number is positive, no need to complement the number If the number is negative, you need to complement the number Convert to decimal Add the negative sign if the number is negative Examples Convert to decimal sign-and-magnitude The number is positive (most significant bit is 0), no need to complement Convert to decimal = 45 = 45 Convert to decimal sign-and-magnitude The number is negative (most significant bit is 1), then first find the complement of the number Find 1 s complement = Convert to decimal = 45 Add the negative sign = -45 Convert to decimal sign-and-magnitude The number is negative (most significant bit is 1), then first find the complement of the number Find 1 s complement = Convert to decimal = 25 Add the negative sign = -25 Addition and Subtraction Arithmetic (1 s complement) Addition in 1 s complement is done using the following method Add the two numbers If there is an end-round carry, add the carry to the result Subtraction in 1 s complement is done using the following method

22 Find 1 s complement of the number with negative sign in front (i.e. eliminate negative sign) Adding the two numbers Examples 1. Add ( ) (i.e = 103) = = 103 in decimal 2. Add ( ) (i.e = 104) = (1) Add end-carry to the result = = = 104 in decimal 3. Subtract ( ) (i.e = -13) Find 1 s complement of the second number = Add the 2 numbers = = = = -13 in decimal 4. Subtract ( ) (i.e = = 108) Find 1 s complement of the second number = Add the 2 numbers = = = = 108 in decimal 2 s Complement Representation The 2 s complement is an alternative complementary representation for signed integers See Figure 4.1 for 2 s complement representation of 8-bit number 2 s complement = 1 s complement s complement solves the dual zero problem (i.e. 0 and +0) found in 1 s complement The 0 is eliminated and the negative scale is shifted to the right by 1 (i.e. add 1) 2 s complement is more common than 1 s complement in computers Advantages Addition arithmetic is faster as it does not require an extra end-round carry step 2 s complement solves the dual zero Disadvantages Finding complement requires one extra step (i.e. adding 1 after inversion) Convert from decimal sign-and-magnitude to 2 s complement Similar to 1 s complement with the following differences: Complement number = invert bits + 1 Examples Convert to 8-bit 2 s complement The number is negative (the sign is -) Convert from decimal to binary =

23 Pad with 0 s to get 8-bit representation = Invert the bits = Add 1 = Convert to 16-bit 2 s complement The number is positive Convert from decimal to binary = Pad with 0 s to get 16-bit representation = = Convert to 16-bit 1 s complement The number is negative (the sign is -) Convert from decimal to binary = Pad with 0 s to get 16-bit representation = Invert the bits = Add 1 = Convert from 2 s complement to decimal sign-and-magnitude Similar to 1 s complement with the following differences: Examples Complement number = invert bits + 1 Convert to decimal sign-and-magnitude The number is positive (most significant bit is 0), no need to complement Convert to decimal = 45 Convert to decimal sign-and-magnitude The number is negative (most significant bit is 1), then first find the complement of the number Find 2 s complement = = Convert to decimal = 46 Since the number is negative, add the negative sign = -46 Convert to decimal sign-and-magnitude The number is negative (most significant bit is 1), then first find the complement of the number Find 2 s complement = = Convert to decimal = 26 Since the number is negative, add the negative sign = -26 Addition and Subtraction Arithmetic (2 s complement) Addition in 2 s complement is similar to 1 s complement with the following differences: The end-carry is dropped rather than added to the result Subtraction in 2 s complement is similar to 1 s complement with the exception

24 2 s complement is found for numbers with negative sign instead of 1 s complement Examples 1. Add ( ) (i.e = 103) = (1) Drop the end carry = = 103 in decimal 2. Add ( ) (i.e = 103) = = 103 in decimal 3. Subtract ( ) (i.e = = 109) Complement the second number to eliminate the negative sign = = = = 109 in decimal 4. Subtract ( ) (i.e = -13) Complement the second number to eliminate the negative sign = = = = -13 in decimal Overflow and Carry Conditions Typically, an overflow occur when the result of calculation does not fit into the storage space In 2 s complement an addition or subtraction overflow occur when the result overflows into the sign bit An overflow can be detected when the sign of the result is an opposite of the sign of both numbers In computers, an overflow flag is used to test for an overflow (flag is set/reset at every calculation) In 2 s complement an addition or subtraction carry occur when the result exceeds the storage space A carry flag is used to test for carry (flag is set/reset at every calculation) Overflow and carry can occur independent of each other 4 possible outcomes as a result of addition or subtraction No overflow and No carry No overflow and carry Overflow and no carry Overflow and carry Overflow produces an incorrect result Carry still produces a correct result

25 Examples (addition of two 4-bit 2 s complement numbers) = = 1010 (4+2 = 6) no overflow and no carry (result is correct) (4+6 = -6) overflow and no carry (result is incorrect) = (1) 1010 (-4-2 = -6) no overflow and carry (result is correct) = (1) 0110 (-4-6 = 6) overflow and carry (result is incorrect) Binary Arithmetic: Addition Adding unsigned numbers Adding unsigned numbers in binary is quite easy. Recall that with 4 bit numbers we can represent numbers from 0 to 15. Addition is done exactly like adding decimal numbers, except that you have only two digits (0 and 1). The only number facts to remember are that 0+0 = 0, with no carry, 1+0 = 1, with no carry, 0+1 = 1, with no carry, 1+1 = 0, and you carry a 1. so to add the numbers 06 10= and 07 10= (answer=13 10=1101 2) we can write out the calculation (the results of any carry is shown along the top row, in italics). Decimal 1 (carry) Unsigned Binary 110 (carry) The only difficulty adding unsigned numbers occurs when you add numbers that are too large. Consider Decimal 0 (carry) Unsigned Binary 1101 (carry) The result is a 5 bit number. So the carry bit from adding the two most significant bits represents a results that overflows (because the sum is too big to be represented with the same number of bits as the two addends). Adding signed numbers Adding signed numbers is not significantly different from adding unsigned numbers. Recall that signed 4 bit numbers (2's complement) can represent numbers between -8 and 7. To see how this addition works, consider three examples. Decimal Signed Binary 1110 (carry) Decimal Signed Binary

26 (carry) Decimal Signed Binary 1100 (carry) In this case the extra carry from the most significant bit has no meaning. With signed numbers there are two ways to get an overflow -- if the result is greater than 7, or less than -8. Let's consider these occurrences now. Decimal Decimal Signed Binary 110 (carry) Signed Binary 1001 (carry) Obviously both of these results are incorrect, but in this case overflow is harder to detect. But you can see that if two numbers with the same sign (either positive or negative) are added and the result has the opposite sign, an overflow has occurred. Adding fractions There is no further difficult in adding two signed fractions, only the interpretation of the results differs. For instance consider addition of two Q3 numbers shown (compare to the example with two 4 bit signed numbers, above). Decimal Fractional Binary (carry) Decimal Fractional Binary (carry) Decimal Fractional Binary (carry)

27 If you look carefully at these examples, you'll see that the binary representation and calculations are the same as before, only the decimal representation has changed. This is very useful because it means we can use the same circuitry for addition, regardless of the interpretation of the results. Even the generation of overflows resulting in error conditions remains unchanged (again compare with above) Decimal Fractional Binary (carry) Decimal Fractional Binary (carry) Multiplication Multiplying unsigned numbers Multiplying unsigned numbers in binary is quite easy. Recall that with 4 bit numbers we can represent numbers from 0 to 15. Multiplication can be performed done exactly as with decimal numbers, except that you have only two digits (0 and 1). The only number facts to remember are that 0*1=0, and 1*1=1 (this is the same as a logical "and"). Multiplication is different than addition in that multiplication of an n bit number by an m bit number results in an n+m bit number. Let's take a look at an example where n=m=4 and the result is 8 bits Decimal Binary Decimal Binary 10 x x x x In this case the result was 7 bit, which can be extended to 8 bits by adding a 0 at the left. When multiplying larger numbers, the result will be 8 bits, with the leftmost set to 1, as shown. As long as there are n+m bits for the result, there is no chance of overflow. For 2 four bit multiplicands, the largest possible product is 15*15=225, which can be represented in 8 bits. Multiplying signed numbers There are many methods to multiply 2's complement numbers. The easiest is to simply find the magnitude of the two multiplicands, multiply these together, and then use the original sign bits to determine the sign of the result. If the multiplicands had the same sign, the result must be positive, if they had different signs, the result is negative. Multiplication by zero is a special case (the result is always zero, with no sign bit).

28 Multiplying fractions As you might expect, the multiplication of fractions can be done in the same way as the multiplication of signed numbers. The magnitudes of the two multiplicands are multiplied, and the sign of the result is determined by the signs of the two multiplicands. There are a couple of complications involved in using fractions. Although it is almost impossible to get an overflow (since the multiplicands and results usually have magnitude less than one), it is possible to get an overflow by multiplying -1x-1 since the result of this is +1, which cannot be represented by fixed point numbers. The other difficulty is that multiplying two Q3 numbers, obviously results in a Q6 number, but we have 8 bits in our result (since we are multiplying two 4 bit numbers). This means that we end up with two bits to the left of the decimal point. These are sign extended, so that for positive numbers they are both zero, and for negative numbers they are both one. Consider the case of multiplying -1/2 by -1/2 (using the method from the textbook): Decimal Fractional Binary -0.5 x x This obviously presents a difficulty if we wanted to store the number in a Q3 result, because if we took just the 4 leftmost bits, we would end up with two sign bits. So what we'd like to do is shift the number to the left by one and then take the 4 leftmost bit. This leaves us with 1110 which is equal to -1/4, as expected. Binary Subtraction For binary subtraction, there are four facts instead of one hundred: 0 0 = = = = 1 The first three are the same as in decimal. The fourth fact is the only new one; it is the borrow case. It applies when the top digit in a column is 0 and the bottom digit is 1. (Remember: in binary, 10 is pronounced one-zero or two. ) Example Subtraction: Now let s subtract from , following the same algorithm used for decimal numbers: Steps of Binary Subtraction Step 1: 1 0 = 1. Step 2: Borrow to make 10 1 = 1. Step 3: Borrow to make 10 1 = 1.

29 Step 4: Cascaded borrow to make 10 1 = 1. Step 5: 1 1 = 0. Step 6: 0 0 = 0. Step 7: Borrow to make 10 1 = 1. Binary Division Binary division is similar to decimal division. It is called as the long division procedure. Example Division Let s return to the example of the introduction, /11. Here it is broken down into steps, following the same algorithm I used for decimal numbers:

30 Steps of Binary Division Step 0 Does 11 go into 1? No, because it s greater than 1. Does 11 go into 10? No, because it s greater than 10. Does 11 go into 101? Yes, because it s less than or equal to 101. (Remember, these are binary numerals; pronounce them one-one, one-zero, onezero-one, etc.) Step 1 1. Divide: Does 11 go into 101? (Yes, we already know that from step 0.) How many times does it go in? One time. There is no guessing. It s easy to see 11 is less than 101, so we know it goes in. And if it goes in, it goes in only once. 2. Multiply: 1 x 11 = 11. (Remember how simple it is to multiply a binary number by a single digit just copy the number down if that single digit is 1, or write down 0 if that single digit is 0.) 3. Subtract: = Bring down: Bring down the 1 to make 101. Step 2 1. Divide: Does 11 go into 101? Yes, 1 time. 2. Multiply: 1 x 11 = Subtract: = Bring down: Bring down the 1 to make 101. Step 3 1. Divide: Does 11 go into 101? Yes, 1 time. 2. Multiply: 1 x 11 = Subtract: = Bring down: Bring down the 1 to make 101. Step 4 1. Divide: Does 11 go into 101? Yes, 1 time. 2. Multiply: 1 x 11 = Subtract: = Bring down: Bring down the 0 to make 100. Step 5 1. Divide: Does 11 go into 100? Yes, 1 time. 2. Multiply: 1 x 11 = Subtract: = Bring down: Bring down the 0 to make 10. Step 6 1. Divide: Does 11 go into 10? No (write down a 0). 2. Multiply: (We don t need to record this step; we re just going to get 0.) 3. Subtract: (We don t need to record this step; we re just going to get 10.) 4. Bring down: Bring down the 0 to make 100. Step 7 We stop here, recognizing that we divided 100 by 11 two steps ago. This means we have a two-digit cycle (10) from here on out. The quotient is

31 Octal Addition Following octal addition table will help you to handle octal addition. To use this table, simply follow the directions used in this example: Add 6 8 and 5 8. Locate 6 in the A column then locate the 5 in the B column. The point in 'sum' area where these two columns intersect is the 'sum' of two numbers = 13 8.

32 Example Addition Addition, Subtraction, Multiplication, Division of two Octal numbers 1. Find addition of (321)8 and (47) Find multiplication of (321)8 and (47) Find Subtraction of (321)8 and (47) Find division of (321)8 and (7) Here, Divisor = 7 Dividend = 321 Quotient = 35 Remainder = 6

33 Octal Subtraction The subtraction of octal numbers follows the same rules as the subtraction of numbers in any other number system. The only variation is in borrowed number. In the decimal system, you borrow a group of In the binary system, you borrow a group of In the octal system you borrow a group of Example Subtraction Hexadecimal Arithmetic The arithmetical operations on base 16 hexadecimal numbers can be performed in the similar they are accomplished on decimal numbers. Tables for hexadecimal addition and multiplication are used for this purpose. The arithmetic operations differ from those done on decimal numbers as described below: 1. The sum 16 is carried over to the next higher place as 1 as 10 is carried over as 1 in decimal addition. 2. When 1 is borrowed from the immediate higher place, it is counted as 16 instead of 10 in decimal subtraction. Let us look into more detail how hexadecimal arithmetical operations are performed. Hexadecimal Arithmetic Examples Hexadecimal Addition: The Addition table below shows the sum for all possible combination of digits in addition

34 Example: Add 16F A Carried over digits 1 6 F + 4 A The digits in unit's place F are 2. From the table, F + 2 = from which 1 is written in unit's place and 1 is carried over to the next higher (16) place. The digits in 16's place are added as A = 7 + A = (From table) out of which, 1 is written down as sum and 1 is carried to the next higher (16 2 ) place. The digits in 16 2 's place add as = Thus 16F A2 16 = Hexadecimal Subtraction: The rule to be remembered for subtraction is the digit borrowed from the immediate higher place is counted as 16. Example: Subtract B4A 16 from C Borrowed B 2 Remaining digit after borrowing C B 4 A E F In units place, A the bigger number is to be subtracted from 9. So, 1 digit from 16's place is borrowed and = 25. A is subtracted from A 16 = F 16 (Note the values of A and F are 10 and 15). As 1 is borrowed from 3, now for the next place 4 is to be subtracted from 2. This again requires borrowing from the next higher place = 18-4 = E 16. Now, for the next place, B is to B subtracted from B remaining after lending 1.B -B = 0. Thus C B4A 16 - = EF 16. Hexadecimal Multiplication: The following table gives products of all combinations of two single digits. While multiplying, if the product consists of two digits, the digit on the left is carried over and added to the product in the next place. Example: Find the product of 1A8 16 and AF Digits carried over in second multiplication 9 7 Digits carried over in first multiplication. 1 A 8 x A F D D

35 First the digit F in the number AF 16 is multiplied with each of the digits in the number 1A8 16. F x 8 = 78. The digit 8 is written below in the product row and 7 is carried over to the next place to be added with the next product. F x A = and = 9D 16. D is written in the product row and 9 is carried over to the next place F x 1 = F. and F = The second row of multiplication is done in a similar manner, by multiplying the digit A with each of the digits in 1A8 16. The two products are then added to get the final product. Thus 1A8 16 x AF 16 = 121D8 16. BCD or Binary Coded Decimal: BCD or Binary Coded Decimal is that number system or code which has the binary numbers or digits to represent a decimal number. A decimal number contains 10 digits (0-9). Now the equivalent binary numbers can be found out of these 10 decimal numbers. In case of BCD the binary number formed by four binary digits, will be the equivalent code for the given decimal digits. In BCD we can use the binary number from only, which are the decimal equivalent from 0-9 respectively. Suppose if a number have single decimal digit then its equivalent Binary Coded Decimal will be the respective four binary digits of that decimal number and if the number contains two decimal digits then its equivalent BCD will be the respective eight binary of the given decimal number. Four for the first decimal digit and next four for the second decimal digit. It may be cleared from an example. Let, (12)10 be the decimal number whose equivalent Binary coded decimal will be Four bits from L.S.B is binary equivalent of 2 and next four is the binary equivalent of 1. Table given below shows the binary and BCD codes for the decimal numbers 0 to 15. From the table below, we can conclude that after 9 the decimal equivalent binary number is of four bit but in case of BCD it is an eight bit number. This is the main difference between Binary number and binary coded decimal. For 0 to 9 decimal numbers both binary and BCD is equal but when decimal number is more than one bit BCD differs from binary.

36 Decimal number Binary number Binary Coded Decimal(BCD) Binary floating point number: Here it is not a decimal point we are moving but a binary point and because it moves it is referred to as floating. What we will look at below is what is referred to as the IEEE 754 Standard for representing floating point numbers. The standard specifies the number of bits used for each section (exponent, mantissa and sign) and the order in which they are represented. The standard specifies the following formats for floating point numbers: Single precision, which uses 32 bits and has the following layout: 1 bit for the sign of the number. 0 means positive and 1 means negative. 8 bits for the exponent. 23 bits for the mantissa. Double precision, which uses 64 bits and has the following layout. 1 bit for the sign of the number. 0 means positive and 1 means negative. 11 bits for the exponent. 52 bits for the mantissa. eg Double precision has more bits, allowing for much larger and much smaller numbers to be represented. As the mantissa is also larger, the degree of accuracy is also

37 increased (remember that many fractions cannot be accurately represented in binary). Whilst double precision floating point numbers have these advantages, they also require more processing power. With increases in CPU processing power and the move to 64 bit computing a lot of programming languages and software just default to double precision. We will look at how single precision floating point numbers work below (just because it's easier). Double precision works exactly the same, just with more bits. The sign bit This is the first bit (left most bit) in the floating point number and it is pretty easy. As mentioned above if your number is positive, make this bit a 0. If your number is negative then make it a 1. The Exponent The exponent gets a little interesting. Remember that the exponent can be positive (to represent large numbers) or negative (to represent small numbers, ie fractions). Your first impression might be that two's complement would be ideal here but the standard has a slightly different approach. This is done as it allows for easier processing and manipulation of floating point numbers. With 8 bits and unsigned binary we may represent the numbers 0 through to 255. To allow for negative numbers in floating point we take our exponent and add 127 to it. The range of exponents we may represent becomes 128 to is not allowed however and is kept as a special case to represent certain special numbers as listed further below. Eg. let's say: We want our exponent to be is 132 so our exponent becomes We want our exponent to be is 120 so our exponent becomes The Mantissa In scientific notation remember that we move the point so that there is only a single (non zero) digit to the left of it. When we do this with binary that digit must be 1 as there is no other alternative. The creators of the floating point standard used this to their advantage to get a little more data represented in a number. After converting a binary number to scientific notation, before storing in the mantissa we drop the leading 1. This allows us to store 1 more bit of data in the mantissa. eg. If our number to store was then in scientific notation it would be with an exponent of 2 (we moved the binary point 2 places to the left). We drop the leading 1. and only need to store If our number to store was then in scientific notation it would be with an exponent of -4 (we moved the binary point 4 places to the right). We drop the leading 1. and only need to store

38 Binary Codes : In the coding, when numbers, letters or words are represented by a specific group of symbols, it is said that the number, letter or word is being encoded. The group of symbols is called as a code. The digital data is represented, stored and transmitted as group of binary bits. This group is also called as binary code. The binary code is represented by the number as well as alphanumeric letter. Advantages of Binary Code Following is the list of advantages that binary code offers. Binary codes are suitable for the computer applications. Binary codes are suitable for the digital communications. Binary codes make the analysis and designing of digital circuits if we use the binary codes. Since only 0 & 1 are being used, implementation becomes easy. Classification of binary codes The codes are broadly categorized into following four categories. Weighted Codes Non-Weighted Codes Binary Coded Decimal Code Alphanumeric Codes Error Detecting Codes Error Correcting Codes Weighted Codes Weighted binary codes are those binary codes which obey the positional weight principle. Each position of the number represents a specific weight. Several systems of the codes are used to express the decimal digits 0 through 9. In these codes each decimal digit is represented by a group of four bits. Non-Weighted Codes In this type of binary codes, the positional weights are not assigned. The examples of non-weighted codes are Excess-3 code and Gray code. Excess-3 code The Excess-3 code is also called as XS-3 code. It is non-weighted code used to express decimal numbers. The Excess-3 code words are derived from the 8421 BCD code words adding (0011)2 or (3)10 to each code word in The excess-3 codes are obtained as follows

39 Example Gray Code It is the non-weighted code and it is not arithmetic codes. That means there are no specific weights assigned to the bit position. It has a very special feature that, only one bit will change each time the decimal number is incremented as shown in fig. As only one bit changes at a time, the gray code is called as a unit distance code. The gray code is a cyclic code. Gray code cannot be used for arithmetic operation. Application of Gray code Gray code is popularly used in the shaft position encoders. A shaft position encoder produces a code word which represents the angular position of the shaft. Binary Coded Decimal (BCD) code In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. In the BCD, with four bits we can represent sixteen numbers (0000 to 1111). But in BCD code only first ten of these are used (0000 to 1001). The remaining six code combinations i.e to 1111 are invalid in BCD.

40 Advantages of BCD Codes It is very similar to decimal system. We need to remember binary equivalent of decimal numbers 0 to 9 only. Disadvantages of BCD Codes The addition and subtraction of BCD have different rules. The BCD arithmetic is little more complicated. BCD needs more number of bits than binary to represent the decimal number. So BCD is less efficient than binary. Alphanumeric codes A binary digit or bit can represent only two symbols as it has only two states '0' or '1'. But this is not enough for communication between two computers because there we need many more symbols for communication. These symbols are required to represent 26 alphabets with capital and small letters, numbers from 0 to 9, punctuation marks and other symbols. The alphanumeric codes are the codes that represent numbers and alphabetic characters. Mostly such codes also represent other characters such as symbol and various instructions necessary for conveying information. An alphanumeric code should at least represent 10 digits and 26 letters of alphabet i.e. total 36 items. The following three alphanumeric codes are very commonly used for the data representation. American Standard Code for Information Interchange (ASCII). Extended Binary Coded Decimal Interchange Code (EBCDIC). Five bit Baudot Code. ASCII code is a 7-bit code whereas EBCDIC is an 8-bit code. ASCII code is more commonly used worldwide while EBCDIC is used primarily in large IBM computers. Decimal Binary Excess-3 Gray Code

41 Error Codes : There are binary code techniques available to detect and correct data during data transmission. What is Error? Error is a condition when the output information does not match with the input information. During transmission, digital signals suffer from noise that can introduce errors in the binary bits travelling from one system to other. That means a 0 bit may change to 1 or a 1 bit may change to 0. Error-Detecting codes Whenever a message is transmitted, it may get scrambled by noise or data may get corrupted. To avoid this, we use error-detecting codes which are additional data added to a given digital message to help us detect if an error occurred during transmission of the message. A simple example of error-detecting code is parity check. Error-Correcting codes Along with error-detecting code, we can also pass some data to figure out the original message from the corrupt message that we received. This type of code is called an error-correcting code. Error-correcting codes also deploy the same strategy as errordetecting codes but additionally, such codes also detect the exact location of the corrupt bit. In error-correcting codes, parity check has a simple way to detect errors along with a sophisticated mechanism to determine the corrupt bit location. Once the corrupt bit is located, its value is reverted (from 0 to 1 or 1 to 0) to get the original message. How to Detect and Correct Errors? To detect and correct the errors, additional bits are added to the data bits at the time of transmission. The additional bits are called parity bits. They allow detection or correction of the errors. The data bits along with the parity bits form a code word. Parity Checking of Error Detection It is the simplest technique for detecting and correcting errors. The MSB of an 8-bits word is used as the parity bit and the remaining 7 bits are used as data or message bits. The parity of 8-bits transmitted word can be either even parity or odd parity.

42 Even parity -- Even parity means the number of 1's in the given word including the parity bit should be even (2,4,6,...). Odd parity -- Odd parity means the number of 1's in the given word including the parity bit should be odd (1,3,5,...). Use of Parity Bit The parity bit can be set to 0 and 1 depending on the type of the parity required. For even parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is even. Shown in fig. (a). For odd parity, this bit is set to 1 or 0 such that the no. of "1 bits" in the entire word is odd. Shown in fig. (b). How Does Error Detection Take Place? Parity checking at the receiver can detect the presence of an error if the parity of the receiver signal is different from the expected parity. That means, if it is known that the parity of the transmitted signal is always going to be "even" and if the received signal has an odd parity, then the receiver can conclude that the received signal is not correct. If an error is detected, then the receiver will ignore the received byte and request for retransmission of the same byte to the transmitter.

43 BOOLEAN ALGEBRA & LOGIC GATES : Logic gates are electronic circuits that can be used to implement the most elementary logic expressions, also known as Boolean expressions. The logic gate is the most basic building block of combinational logic. There are three basic logic gates, namely the OR gate, the AND gate and the NOT gate. Other logic gates that are derived from these basic gates are the NAND gate, the NOR gate, the EXCLUSIVEOR gate and the EXCLUSIVE-NOR gate. This chapter deals with logic gates and implementations using NAND and NOR gates followed by simplification of Boolean functions using Boolean Laws and theorems and using K-maps. Positive and Negative Logic The binary variables can have either of the two states, i.e. the logic 0 state or the logic 1 state. These logic states in digital systems such as computers, for instance, are represented by two different voltage levels or two different current levels. If the more positive of the two voltage or current levels represents a logic 1 and the less positive of the two levels represents a logic 0, then the logic system is referred to as a positive logic system. If the more positive of the two voltage or current levels represents a logic 0 and the less positive of the two levels represents a logic 1, then the logic system is referred to as a negative logic system. If the two voltage levels are 0 V and +5 V, then in the positive logic system the 0 V represents logic 0 and the +5 V represents logic 1. In the negative logic system, 0 V represents logic 1 and 5 V represents logic 0. If the two voltage levels are 0 V and 5 V, then in the positive logic system the 0 V represents a logic 1 and the 5 V represents a logic 0. In the negative logic system, 0 V represents logic 0 and 5 V represents logic 1. Logic Gates The logic gate is the most basic building block of any digital system, including computers. Each one of the basic logic gates is a piece of hardware or an electronic circuit that can be used to implement some basic logic expression. While laws of Boolean algebra could be used to do manipulation with binary variables and simplify logic expressions, these are actually implemented in a digital system with the help of electronic circuits called logic gates. The three basic logic gates are the OR gate, the AND gate and the NOT gate. OR Gate A logic gate used to perform the operation of logical addition is called an OR gate. An OR gate performs an ORing operation on two or more than two logic variables. The OR operation on two independent logic variables A and B is written as Y = A+B and reads as Y equals A OR B. An OR gate is a logic circuit with two or more inputs and one output. The output of an OR gate is LOW only when all of its inputs are LOW. For all other possible input combinations, the output is HIGH. A truth table lists all possible combinations of input binary variables and the corresponding outputs of a logic system. Figure shows the circuit symbol and the truth table of a two-input OR gate. The operation of a two-input OR gate is explained by the logic expression

44 Y = A+B Two input OR Gate AND Gate : A logic gate used to perform logical multiplication is known as AND gate. An AND gate is a logic circuit having two or more inputs and one output. The output of an AND gate is HIGH only when all of its inputs are in the HIGH state. In all other cases, the output is LOW. The logic symbol and truth table of a two-input AND gate is shown in figure. The AND operation on two independent logic variables A and B is written as Y = A.B and reads as Y equals A AND B. The operation of a two-input AND gate is explained by the logic expression Y = A.B Two input AND Gate NOT Gate A logic gate used to perform logical inversion is known as a NOT gate. A NOT gate is a one -input, one-output logic circuit whose output is always the complement of the input. That is, a LOW input produces a HIGH output, and vice versa. If is the input to a NOT circuit, then its output Y is given by Y = or and reads as Y equals NOT. The logic symbol and truth table of a NOT gate is shown in figure. The operation of a NOT gate is explained by the logic expression Y = A NAND Gate NOT Gate NAND stands for NOT AND. An AND gate followed by a NOT circuit makes it a NAND gate. The output of a NAND gate is logic 0 when all its inputs are logic 1. For all other input combinations, the output is logic 1. The symbol and truth table of a NAND gate is as shown. NAND gate operation is logically expressed as Y = A.B Two input NAND Gate NAND Gate is known as Universal gate as it can be used alone to implement any gate operation. Hence it is said to be functionally complete.

45 NOR Gate NOR stands for NOT OR. An OR gate followed by a NOT circuit makes it a NOR gate. The output of a NOR gate is logic 1 when all its inputs are logic 0. For all other input combinations, the output is logic 0. The symbol and truth table of a NOR gate is as shown. The output of a two-input NOR gate is logically expressed as Y = A+B Two input NOR Gate NOR gate is also known as Universal gate as it is used alone to implement any gate operation and hence it is also functionally complete. EXCLUSIVE-OR Gate The EXCLUSIVE-OR gate, commonly written as EX-OR gate, is a two-input, one-output gate. The output of an EX-OR gate is logic 1 when the inputs are unlike and logic 0 when the inputs are like. Although EX-OR gates are available in integrated circuit form only as two-input gates, unlike other gates which are available in multiple inputs also, multiple-input EX-OR logic functions can be implemented using more than one twoinput gates. The output of a multiple-input EX-OR logic function is logic 1 when the number of 1s in the input sequence is odd and logic 0 when the number of 1s in the input sequence is even, including zero. The symbol and truth table of an EX-OR gate is shown in figure. The output of a two-input EX-OR gate is logically expressed as EXCLUSIVE-NOR Gate Two input EX-OR Gate EXCLUSIVE-NOR (commonly written as EX-NOR) means NOT of EX-OR, i.e. the logic gate that we get by complementing the output of an EX-OR gate. The truth table of an EX-NOR gate is obtained from the truth table of an EX-OR gate by complementing the output entries as shown in figure. Logically, Two input EX-NOR Gate The output of a two-input EX-NOR gate is logic 1 when the inputs are like and logic 0 when they are unlike. In general, the output of a multiple-input EX-NOR logic function is logic 0 when the number of 1s in the input sequence is odd and a logic 1 when the number of 1s in the input sequence is even including zero.

46 Boolean algebra: Boolean algebra is an algebraic structure defined on a set of elements B together with two binary operators + and provided the following postulates are satisfied: Boolean Laws & Theorems: Duality Principle: It states that every algebraic expression deducible from the postulates of Boolean algebra remains valid if the operators and identity elements are interchanged. If the dual of an algebraic expression is desired, OR and AND operators are interchanged and 1 s are replaced by 0 s and 0 s by 1 s. DeMorgan s Theorem: Absorption Theorem: Simplification using Boolean Laws & Theorems: The Boolean functions can be simplified by using appropriate Boolean laws and theorems. Examples: Simplify the following functions using Boolean laws and theorems:

47 Universal Gates OR, AND and NOT gates are the three basic logic gates as they together can be used to construct the logic circuit for any given Boolean expression. NOR and NAND gates have the property that they individually can be used to hardware-implement a logic circuit corresponding to any given Boolean expression. That is, it is possible to use either only NAND gates or only NOR gates to implement any Boolean expression. This is so because a combination of NAND gates or a combination of NOR gates can be used to perform functions of any of the basic logic gates. It is for this reason that NAND and NOR gates are universal gates. Implementation of gates using NAND gates a) NOT gate: b) AND gate: c) OR gate: d) NOR gate:

48 e) Ex-OR gate: f) Ex-NOR gate: Implementation of gates using NOR gates a) NOT gate: b) AND gate: c) OR gate: d) NAND gate: e) Ex-OR gate:

49 f) Ex-NOR gate: Boolean Expressions: A Boolean expression or a function is an expression which consists of binary variables joined by the Boolean connectives AND and OR along with NOT operation. Any Boolean expression can be expressed in two forms: a) Canonical form b) Standard form Canonical Form: An expanded form of Boolean expression, where each term contains all Boolean variables in their true or complemented form, is known as the canonical form of the expression. a) Sum of minterms: Any Boolean function can be expressed as a sum of minterms expression. A minterm is a standard product which consists of all variables in either complemented or un-complemented form for which the output is 1. For example, is a sum of minterms expression with three variables. b) Product of maxterms: Any Boolean function can be expressed as a product of maxterms expression. A maxterm is a standard sum which consists of all variables in either complemented or un-complemented form for which the output is 0. For example, Standard Form: is a product of maxterms expression with three variables. A simplified form of a Boolean expression which may consist of one or more number of variables in each term in either complemented or un-complemented form, is known as Standard form of the expression.

50 a) Sum of Products (SOP): The sum of products is a Boolean expression containing AND terms, called Product terms, of one or more literals each; the sum denotes the ORing of these terms. For example, is a SOP expression with three variables. b) Product of Sums (POS): It is a Boolean expression containing OR terms called Sum terms and the product denotes the ANDing of these terms. is a POS expression with three variables. ** Canonical form is obtained when a function is taken from a truth table. When Implementing a Boolean function with gates, standard form is preferred. Simplification of Boolean expressions: The primary objective of all simplification procedures is to obtain an expression that has the minimum number of terms. Obtaining an expression with the minimum number of literals is usually the secondary objective. The Boolean functions can be simplified by using a) Boolean Laws and theorems b) K maps c) Quine Mc-Cluskey or Tabulation Method Simplification using K-maps: A Karnaugh map is a graphical representation of the logic system. It can be drawn directly from either minterm (sum-of-products) or maxterm (product-of-sums) Boolean expressions. Drawing a Karnaugh map from the truth table involves an additional step of writing the minterm or maxterm expression depending upon whether it is desired to have a minimized sum-of-products or a minimized product of sums expression. An n-variable Karnaugh map has 2 n squares, and each possible input is allotted a square. In the case of a minterm Karnaugh map, 1 is placed in all those squares for which the output is 1, and 0 is placed in all those squares for which the output is 0. 0s are omitted for simplicity. An X is placed in squares corresponding to don t care conditions. a) Two Variable K-map:

51 i) Sum of minterms representation ii) Product of maxterms representation b) Three Variable K-map: i) Sum of minterms representation ii) Product of maxterms representation c) Four Variable K-map: i) Sum of minterms representation ii) Product of maxterms representation d) Five Variable K-map:

52 Simplification Algorithm: Simplification of logical functions using K-maps is based on the principle of combining terms in adjacent cells. Two cells are said to be adjacent if they differ in only one variable. 1. Identify the ones which cannot be combined with any other ones and encircle them. These are called essential prime implicants. 2. Identify the ones that can be combined in groups of two in only one way. Encircle them. 3. Identify the ones that can be combined with three other ones, to make a group of four adjacent ones, in only one way. Encircle such group of ones. 4. Identify the ones that can be combined with seven other ones, to make a group of eight adjacent ones, in only one way. Encircle them. 5. After identifying the essential groups of 2, 4, and 8 ones, if there still remain some ones which have not been encircled, then these are to be combined with each other or with other already encircled ones. Examples:

53

CHW 261: Logic Design

CHW 261: Logic Design CHW 261: Logic Design Instructors: Prof. Hala Zayed Dr. Ahmed Shalaby http://www.bu.edu.eg/staff/halazayed14 http://bu.edu.eg/staff/ahmedshalaby14# Slide 1 Slide 2 Slide 3 Digital Fundamentals CHAPTER

More information

Module 2: Computer Arithmetic

Module 2: Computer Arithmetic Module 2: Computer Arithmetic 1 B O O K : C O M P U T E R O R G A N I Z A T I O N A N D D E S I G N, 3 E D, D A V I D L. P A T T E R S O N A N D J O H N L. H A N N E S S Y, M O R G A N K A U F M A N N

More information

Number representations

Number representations Number representations Number bases Three number bases are of interest: Binary, Octal and Hexadecimal. We look briefly at conversions among them and between each of them and decimal. Binary Base-two, or

More information

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM

DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) COURSE / CODE NUMBER SYSTEM COURSE / CODE DIGITAL SYSTEM FUNDAMENTALS (ECE 421) DIGITAL ELECTRONICS FUNDAMENTAL (ECE 422) NUMBER SYSTEM A considerable subset of digital systems deals with arithmetic operations. To understand the

More information

COMP Overview of Tutorial #2

COMP Overview of Tutorial #2 COMP 1402 Winter 2008 Tutorial #2 Overview of Tutorial #2 Number representation basics Binary conversions Octal conversions Hexadecimal conversions Signed numbers (signed magnitude, one s and two s complement,

More information

BINARY SYSTEM. Binary system is used in digital systems because it is:

BINARY SYSTEM. Binary system is used in digital systems because it is: CHAPTER 2 CHAPTER CONTENTS 2.1 Binary System 2.2 Binary Arithmetic Operation 2.3 Signed & Unsigned Numbers 2.4 Arithmetic Operations of Signed Numbers 2.5 Hexadecimal Number System 2.6 Octal Number System

More information

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM

1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1. NUMBER SYSTEMS USED IN COMPUTING: THE BINARY NUMBER SYSTEM 1.1 Introduction Given that digital logic and memory devices are based on two electrical states (on and off), it is natural to use a number

More information

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr

Number Systems and Binary Arithmetic. Quantitative Analysis II Professor Bob Orr Number Systems and Binary Arithmetic Quantitative Analysis II Professor Bob Orr Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems

More information

Number Systems CHAPTER Positional Number Systems

Number Systems CHAPTER Positional Number Systems CHAPTER 2 Number Systems Inside computers, information is encoded as patterns of bits because it is easy to construct electronic circuits that exhibit the two alternative states, 0 and 1. The meaning of

More information

D I G I T A L C I R C U I T S E E

D I G I T A L C I R C U I T S E E D I G I T A L C I R C U I T S E E Digital Circuits Basic Scope and Introduction This book covers theory solved examples and previous year gate question for following topics: Number system, Boolean algebra,

More information

Level ISA3: Information Representation

Level ISA3: Information Representation Level ISA3: Information Representation 1 Information as electrical current At the lowest level, each storage unit in a computer s memory is equipped to contain either a high or low voltage signal Each

More information

Number System. Introduction. Decimal Numbers

Number System. Introduction. Decimal Numbers Number System Introduction Number systems provide the basis for all operations in information processing systems. In a number system the information is divided into a group of symbols; for example, 26

More information

Digital Fundamentals

Digital Fundamentals Digital Fundamentals Tenth Edition Floyd Chapter 2 2009 Pearson Education, Upper 2008 Pearson Saddle River, Education NJ 07458. All Rights Reserved Decimal Numbers The position of each digit in a weighted

More information

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS

DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS C H A P T E R 6 DIGITAL ARITHMETIC: OPERATIONS AND CIRCUITS OUTLINE 6- Binary Addition 6-2 Representing Signed Numbers 6-3 Addition in the 2 s- Complement System 6-4 Subtraction in the 2 s- Complement

More information

Chapter 2: Number Systems

Chapter 2: Number Systems Chapter 2: Number Systems Logic circuits are used to generate and transmit 1s and 0s to compute and convey information. This two-valued number system is called binary. As presented earlier, there are many

More information

Binary Addition. Add the binary numbers and and show the equivalent decimal addition.

Binary Addition. Add the binary numbers and and show the equivalent decimal addition. Binary Addition The rules for binary addition are 0 + 0 = 0 Sum = 0, carry = 0 0 + 1 = 0 Sum = 1, carry = 0 1 + 0 = 0 Sum = 1, carry = 0 1 + 1 = 10 Sum = 0, carry = 1 When an input carry = 1 due to a previous

More information

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997

Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 Excerpt from: Stephen H. Unger, The Essence of Logic Circuits, Second Ed., Wiley, 1997 APPENDIX A.1 Number systems and codes Since ten-fingered humans are addicted to the decimal system, and since computers

More information

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes

Digital Fundamentals. CHAPTER 2 Number Systems, Operations, and Codes Digital Fundamentals CHAPTER 2 Number Systems, Operations, and Codes Decimal Numbers The decimal number system has ten digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 The decimal numbering system has a base of

More information

Internal Data Representation

Internal Data Representation Appendices This part consists of seven appendices, which provide a wealth of reference material. Appendix A primarily discusses the number systems and their internal representation. Appendix B gives information

More information

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal

Positional notation Ch Conversions between Decimal and Binary. /continued. Binary to Decimal Positional notation Ch.. /continued Conversions between Decimal and Binary Binary to Decimal - use the definition of a number in a positional number system with base - evaluate the definition formula using

More information

COMPUTER ARITHMETIC (Part 1)

COMPUTER ARITHMETIC (Part 1) Eastern Mediterranean University School of Computing and Technology ITEC255 Computer Organization & Architecture COMPUTER ARITHMETIC (Part 1) Introduction The two principal concerns for computer arithmetic

More information

CS & IT Conversions. Magnitude 10,000 1,

CS & IT Conversions. Magnitude 10,000 1, CS & IT Conversions There are several number systems that you will use when working with computers. These include decimal, binary, octal, and hexadecimal. Knowing how to convert between these number systems

More information

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010

Number Systems and Conversions UNIT 1 NUMBER SYSTEMS & CONVERSIONS. Number Systems (2/2) Number Systems (1/2) Iris Hui-Ru Jiang Spring 2010 Contents Number systems and conversion Binary arithmetic Representation of negative numbers Addition of two s complement numbers Addition of one s complement numbers Binary s Readings Unit.~. UNIT NUMBER

More information

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem ahmadsm AT kfupm Phone: Office:

COE 202: Digital Logic Design Number Systems Part 2. Dr. Ahmad Almulhem   ahmadsm AT kfupm Phone: Office: COE 0: Digital Logic Design Number Systems Part Dr. Ahmad Almulhem Email: ahmadsm AT kfupm Phone: 860-7554 Office: -34 Objectives Arithmetic operations: Binary number system Other number systems Base Conversion

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

MACHINE LEVEL REPRESENTATION OF DATA

MACHINE LEVEL REPRESENTATION OF DATA MACHINE LEVEL REPRESENTATION OF DATA CHAPTER 2 1 Objectives Understand how integers and fractional numbers are represented in binary Explore the relationship between decimal number system and number systems

More information

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS

CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS CPE 323 REVIEW DATA TYPES AND NUMBER REPRESENTATIONS IN MODERN COMPUTERS Aleksandar Milenković The LaCASA Laboratory, ECE Department, The University of Alabama in Huntsville Email: milenka@uah.edu Web:

More information

Number Systems. Both numbers are positive

Number Systems. Both numbers are positive Number Systems Range of Numbers and Overflow When arithmetic operation such as Addition, Subtraction, Multiplication and Division are performed on numbers the results generated may exceed the range of

More information

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0

Integers. N = sum (b i * 2 i ) where b i = 0 or 1. This is called unsigned binary representation. i = 31. i = 0 Integers So far, we've seen how to convert numbers between bases. How do we represent particular kinds of data in a certain (32-bit) architecture? We will consider integers floating point characters What

More information

Chapter 3 Data Representation

Chapter 3 Data Representation Chapter 3 Data Representation The focus of this chapter is the representation of data in a digital computer. We begin with a review of several number systems (decimal, binary, octal, and hexadecimal) and

More information

Chapter 1 Review of Number Systems

Chapter 1 Review of Number Systems 1.1 Introduction Chapter 1 Review of Number Systems Before the inception of digital computers, the only number system that was in common use is the decimal number system which has a total of 10 digits

More information

Numbering systems. Dr Abu Arqoub

Numbering systems. Dr Abu Arqoub Numbering systems The decimal numbering system is widely used, because the people Accustomed (معتاد) to use the hand fingers in their counting. But with the development of the computer science another

More information

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

1010 2?= ?= CS 64 Lecture 2 Data Representation. Decimal Numbers: Base 10. Reading: FLD Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 CS 64 Lecture 2 Data Representation Reading: FLD 1.2-1.4 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Example: 3271 = (3x10 3 ) + (2x10 2 ) + (7x10 1 ) + (1x10 0 ) 1010 10?= 1010 2?= 1

More information

CHAPTER 5: Representing Numerical Data

CHAPTER 5: Representing Numerical Data CHAPTER 5: Representing Numerical Data The Architecture of Computer Hardware and Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint

More information

Chapter 5: Computer Arithmetic. In this chapter you will learn about:

Chapter 5: Computer Arithmetic. In this chapter you will learn about: Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction (-) Multiplication

More information

Signed Binary Numbers

Signed Binary Numbers Signed Binary Numbers Unsigned Binary Numbers We write numbers with as many digits as we need: 0, 99, 65536, 15000, 1979, However, memory locations and CPU registers always hold a constant, fixed number

More information

Number Systems Base r

Number Systems Base r King Fahd University of Petroleum & Minerals Computer Engineering Dept COE 2 Fundamentals of Computer Engineering Term 22 Dr. Ashraf S. Hasan Mahmoud Rm 22-44 Ext. 724 Email: ashraf@ccse.kfupm.edu.sa 3/7/23

More information

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other

Kinds Of Data CHAPTER 3 DATA REPRESENTATION. Numbers Are Different! Positional Number Systems. Text. Numbers. Other Kinds Of Data CHAPTER 3 DATA REPRESENTATION Numbers Integers Unsigned Signed Reals Fixed-Point Floating-Point Binary-Coded Decimal Text ASCII Characters Strings Other Graphics Images Video Audio Numbers

More information

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems

Decimal & Binary Representation Systems. Decimal & Binary Representation Systems Decimal & Binary Representation Systems Decimal & binary are positional representation systems each position has a value: d*base i for example: 321 10 = 3*10 2 + 2*10 1 + 1*10 0 for example: 101000001

More information

Learning Objectives. Binary over Decimal. In this chapter you will learn about:

Learning Objectives. Binary over Decimal. In this chapter you will learn about: Ref Page Slide 1/29 Learning Objectives In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations using binary numbers Addition (+) Subtraction

More information

Divide: Paper & Pencil

Divide: Paper & Pencil Divide: Paper & Pencil 1001 Quotient Divisor 1000 1001010 Dividend -1000 10 101 1010 1000 10 Remainder See how big a number can be subtracted, creating quotient bit on each step Binary => 1 * divisor or

More information

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design

COE 202- Digital Logic. Number Systems II. Dr. Abdulaziz Y. Barnawi COE Department KFUPM. January 23, Abdulaziz Barnawi. COE 202 Logic Design 1 COE 0- Digital Logic Number Systems II Dr. Abdulaziz Y. Barnawi COE Department KFUPM COE 0 Logic Design January 3, 016 Objectives Base Conversion Decimal to other bases Binary to Octal and Hexadecimal

More information

NUMBER SYSTEMS AND CODES

NUMBER SYSTEMS AND CODES C H A P T E R 69 Learning Objectives Number Systems The Decimal Number System Binary Number System Binary to Decimal Conversion Binary Fractions Double-Dadd Method Decimal to Binary Conversion Shifting

More information

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal

Basic Definition INTEGER DATA. Unsigned Binary and Binary-Coded Decimal. BCD: Binary-Coded Decimal Basic Definition REPRESENTING INTEGER DATA Englander Ch. 4 An integer is a number which has no fractional part. Examples: -2022-213 0 1 514 323434565232 Unsigned and -Coded Decimal BCD: -Coded Decimal

More information

In this lesson you will learn: how to add and multiply positive binary integers how to work with signed binary numbers using two s complement how fixed and floating point numbers are used to represent

More information

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC

CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-1 CHAPTER V CHAPTER V NUMBER SYSTEMS AND ARITHMETIC CHAPTER V-2 NUMBER SYSTEMS RADIX-R REPRESENTATION Decimal number expansion 73625 10 = ( 7 10 4 ) + ( 3 10 3 ) + ( 6 10 2 ) + ( 2 10 1 ) +(

More information

Chapter 5 : Computer Arithmetic

Chapter 5 : Computer Arithmetic Chapter 5 Computer Arithmetic Integer Representation: (Fixedpoint representation): An eight bit word can be represented the numbers from zero to 255 including = 1 = 1 11111111 = 255 In general if an nbit

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-2700: Digital Logic Design Winter Notes - Unit 4. hundreds. UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers of ): DIGIT 3 4 5 6 7 8 9 Number:

More information

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems

SCHOOL OF ENGINEERING & BUILT ENVIRONMENT. Mathematics. Numbers & Number Systems SCHOOL OF ENGINEERING & BUILT ENVIRONMENT Mathematics Numbers & Number Systems Introduction Numbers and Their Properties Multiples and Factors The Division Algorithm Prime and Composite Numbers Prime Factors

More information

Number Systems and Computer Arithmetic

Number Systems and Computer Arithmetic Number Systems and Computer Arithmetic Counting to four billion two fingers at a time What do all those bits mean now? bits (011011011100010...01) instruction R-format I-format... integer data number text

More information

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System

Moodle WILLINGDON COLLEGE SANGLI. ELECTRONICS (B. Sc.-I) Introduction to Number System Moodle 1 WILLINGDON COLLEGE SANGLI ELECTRONICS (B. Sc.-I) Introduction to Number System E L E C T R O N I C S Introduction to Number System and Codes Moodle developed By Dr. S. R. Kumbhar Department of

More information

Lecture 8: Addition, Multiplication & Division

Lecture 8: Addition, Multiplication & Division Lecture 8: Addition, Multiplication & Division Today s topics: Signed/Unsigned Addition Multiplication Division 1 Signed / Unsigned The hardware recognizes two formats: unsigned (corresponding to the C

More information

Arithmetic Processing

Arithmetic Processing CS/EE 5830/6830 VLSI ARCHITECTURE Chapter 1 Basic Number Representations and Arithmetic Algorithms Arithmetic Processing AP = (operands, operation, results, conditions, singularities) Operands are: Set

More information

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand

Digital Arithmetic. Digital Arithmetic: Operations and Circuits Dr. Farahmand Digital Arithmetic Digital Arithmetic: Operations and Circuits Dr. Farahmand Binary Arithmetic Digital circuits are frequently used for arithmetic operations Fundamental arithmetic operations on binary

More information

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds.

ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT, OAKLAND UNIVERSITY ECE-278: Digital Logic Design Fall Notes - Unit 4. hundreds. ECE-78: Digital Logic Design Fall 6 UNSIGNED INTEGER NUMBERS Notes - Unit 4 DECIMAL NUMBER SYSTEM A decimal digit can take values from to 9: Digit-by-digit representation of a positive integer number (powers

More information

Introduction to Numbering Systems

Introduction to Numbering Systems NUMBER SYSTEM Introduction to Numbering Systems We are all familiar with the decimal number system (Base 10). Some other number systems that we will work with are Binary Base 2 Octal Base 8 Hexadecimal

More information

MC1601 Computer Organization

MC1601 Computer Organization MC1601 Computer Organization Unit 1 : Digital Fundamentals Lesson1 : Number Systems and Conversions (KSB) (MCA) (2009-12/ODD) (2009-10/1 A&B) Coverage - Lesson1 Shows how various data types found in digital

More information

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar

Data Representation COE 301. Computer Organization Prof. Muhamed Mudawar Data Representation COE 30 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline Positional Number

More information

Final Labs and Tutors

Final Labs and Tutors ICT106 Fundamentals of Computer Systems - Topic 2 REPRESENTATION AND STORAGE OF INFORMATION Reading: Linux Assembly Programming Language, Ch 2.4-2.9 and 3.6-3.8 Final Labs and Tutors Venue and time South

More information

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects:

Numeral Systems. -Numeral System -Positional systems -Decimal -Binary -Octal. Subjects: Numeral Systems -Numeral System -Positional systems -Decimal -Binary -Octal Subjects: Introduction A numeral system (or system of numeration) is a writing system for expressing numbers, that is a mathematical

More information

Computer Organization

Computer Organization Computer Organization Register Transfer Logic Number System Department of Computer Science Missouri University of Science & Technology hurson@mst.edu 1 Decimal Numbers: Base 10 Digits: 0, 1, 2, 3, 4, 5,

More information

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer.

Computer Arithmetic. In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Computer Arithmetic In this article we look at the way in which numbers are represented in binary form and manipulated in a computer. Numbers have a long history. In Europe up to about 400 numbers were

More information

Chapter 5: Computer Arithmetic

Chapter 5: Computer Arithmetic Slide 1/29 Learning Objectives Computer Fundamentals: Pradeep K. Sinha & Priti Sinha In this chapter you will learn about: Reasons for using binary instead of decimal numbers Basic arithmetic operations

More information

Bits, Words, and Integers

Bits, Words, and Integers Computer Science 52 Bits, Words, and Integers Spring Semester, 2017 In this document, we look at how bits are organized into meaningful data. In particular, we will see the details of how integers are

More information

TOPIC: NUMBER SYSTEMS

TOPIC: NUMBER SYSTEMS Ministry of Secondary Education Progressive Comprehensive High School PCHS Mankon Bamenda Department of Computer Studies Republic of Cameroon Peace Work - Fatherland TOPIC: NUMBER SYSTEMS Class: Comp.

More information

Chapter 4 Section 2 Operations on Decimals

Chapter 4 Section 2 Operations on Decimals Chapter 4 Section 2 Operations on Decimals Addition and subtraction of decimals To add decimals, write the numbers so that the decimal points are on a vertical line. Add as you would with whole numbers.

More information

carry in carry 1101 carry carry

carry in carry 1101 carry carry Chapter Binary arithmetic Arithmetic is the process of applying a mathematical operator (such as negation or addition) to one or more operands (the values being operated upon). Binary arithmetic works

More information

UNIT-III COMPUTER ARTHIMETIC

UNIT-III COMPUTER ARTHIMETIC UNIT-III COMPUTER ARTHIMETIC INTRODUCTION Arithmetic Instructions in digital computers manipulate data to produce results necessary for the of activity solution of computational problems. These instructions

More information

CS 101: Computer Programming and Utilization

CS 101: Computer Programming and Utilization CS 101: Computer Programming and Utilization Jul-Nov 2017 Umesh Bellur (cs101@cse.iitb.ac.in) Lecture 3: Number Representa.ons Representing Numbers Digital Circuits can store and manipulate 0 s and 1 s.

More information

Number Systems and Their Representations

Number Systems and Their Representations Number Representations Cptr280 Dr Curtis Nelson Number Systems and Their Representations In this presentation you will learn about: Representation of numbers in computers; Signed vs. unsigned numbers;

More information

CO212 Lecture 10: Arithmetic & Logical Unit

CO212 Lecture 10: Arithmetic & Logical Unit CO212 Lecture 10: Arithmetic & Logical Unit Shobhanjana Kalita, Dept. of CSE, Tezpur University Slides courtesy: Computer Architecture and Organization, 9 th Ed, W. Stallings Integer Representation For

More information

Chapter 2. Data Representation in Computer Systems

Chapter 2. Data Representation in Computer Systems Chapter 2 Data Representation in Computer Systems Chapter 2 Objectives Understand the fundamentals of numerical data representation and manipulation in digital computers. Master the skill of converting

More information

Digital Fundamentals

Digital Fundamentals Digital Fundamentals Tenth Edition Floyd Chapter 1 Modified by Yuttapong Jiraraksopakun Floyd, Digital Fundamentals, 10 th 2008 Pearson Education ENE, KMUTT ed 2009 Analog Quantities Most natural quantities

More information

Number Systems MA1S1. Tristan McLoughlin. November 27, 2013

Number Systems MA1S1. Tristan McLoughlin. November 27, 2013 Number Systems MA1S1 Tristan McLoughlin November 27, 2013 http://en.wikipedia.org/wiki/binary numeral system http://accu.org/index.php/articles/1558 http://www.binaryconvert.com http://en.wikipedia.org/wiki/ascii

More information

Chapter 10 - Computer Arithmetic

Chapter 10 - Computer Arithmetic Chapter 10 - Computer Arithmetic Luis Tarrataca luis.tarrataca@gmail.com CEFET-RJ L. Tarrataca Chapter 10 - Computer Arithmetic 1 / 126 1 Motivation 2 Arithmetic and Logic Unit 3 Integer representation

More information

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal.

Math in MIPS. Subtracting a binary number from another binary number also bears an uncanny resemblance to the way it s done in decimal. Page < 1 > Math in MIPS Adding and Subtracting Numbers Adding two binary numbers together is very similar to the method used with decimal numbers, except simpler. When you add two binary numbers together,

More information

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng

Slide Set 1. for ENEL 339 Fall 2014 Lecture Section 02. Steve Norman, PhD, PEng Slide Set 1 for ENEL 339 Fall 2014 Lecture Section 02 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary Fall Term, 2014 ENEL 353 F14 Section

More information

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom.

Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm. Nathan Pihlstrom. Logic Circuits I ECE 1411 Thursday 4:45pm-7:20pm Nathan Pihlstrom www.uccs.edu/~npihlstr My Background B.S.E.E. from Colorado State University M.S.E.E. from Colorado State University M.B.A. from UCCS Ford

More information

Computer Arithmetic. Appendix A Fall 2003 Lec.03-58

Computer Arithmetic. Appendix A Fall 2003 Lec.03-58 Computer Arithmetic Appendix A 18-347 Fall 2003 Lec.03-58 Intro Computer Arithmetic Computers use the binary system Easy to implement in electronics: 1 is 1V, 0 is 0V Easy to implement with switches (transistors!)

More information

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums

plc numbers Encoded values; BCD and ASCII Error detection; parity, gray code and checksums plc numbers - 3. 3. NUMBERS AND DATA Topics: Number bases; binary, octal,, hexa Binary calculations; s compliments, addition, subtraction and Boolean operations Encoded values; BCD and ASCII Error detection;

More information

Microcomputers. Outline. Number Systems and Digital Logic Review

Microcomputers. Outline. Number Systems and Digital Logic Review Microcomputers Number Systems and Digital Logic Review Lecture 1-1 Outline Number systems and formats Common number systems Base Conversion Integer representation Signed integer representation Binary coded

More information

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION

ECOM 2325 Computer Organization and Assembly Language. Instructor: Ruba A.Salamah INTRODUCTION ECOM 2325 Computer Organization and Assembly Language Instructor: Ruba A.Salamah INTRODUCTION Overview Welcome to ECOM 2325 Assembly-, Machine-, and High-Level Languages Assembly Language Programming Tools

More information

Signed umbers. Sign/Magnitude otation

Signed umbers. Sign/Magnitude otation Signed umbers So far we have discussed unsigned number representations. In particular, we have looked at the binary number system and shorthand methods in representing binary codes. With m binary digits,

More information

Octal and Hexadecimal Integers

Octal and Hexadecimal Integers Octal and Hexadecimal Integers CS 350: Computer Organization & Assembler Language Programming A. Why? Octal and hexadecimal numbers are useful for abbreviating long bitstrings. Some operations on octal

More information

Digital Logic Circuits Volume I Digital Number Systems

Digital Logic Circuits Volume I Digital Number Systems PDHonline Course E377 (5 PDH) Digital Logic Circuits Volume I Digital Number Systems Instructor: Lee Layton, P.E 2012 PDH Online PDH Center 5272 Meadow Estates Drive Fairfax, VA 22030-6658 Phone & Fax:

More information

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER

CHAPTER TWO. Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 1 CHAPTER TWO Data Representation ( M.MORRIS MANO COMPUTER SYSTEM ARCHITECTURE THIRD EDITION ) IN THIS CHAPTER 2-1 Data Types 2-2 Complements 2-3 Fixed-Point Representation 2-4 Floating-Point Representation

More information

COMP2611: Computer Organization. Data Representation

COMP2611: Computer Organization. Data Representation COMP2611: Computer Organization Comp2611 Fall 2015 2 1. Binary numbers and 2 s Complement Numbers 3 Bits: are the basis for binary number representation in digital computers What you will learn here: How

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Data Representation ti and Arithmetic for Computers Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Questions What do you know about

More information

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC

Semester Transition Point. EE 109 Unit 11 Binary Arithmetic. Binary Arithmetic ARITHMETIC 1 2 Semester Transition Point EE 109 Unit 11 Binary Arithmetic At this point we are going to start to transition in our class to look more at the hardware organization and the low-level software that is

More information

THE LOGIC OF COMPOUND STATEMENTS

THE LOGIC OF COMPOUND STATEMENTS CHAPTER 2 THE LOGIC OF COMPOUND STATEMENTS Copyright Cengage Learning. All rights reserved. SECTION 2.5 Application: Number Systems and Circuits for Addition Copyright Cengage Learning. All rights reserved.

More information

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer.

Digital Logic. The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. Digital Logic 1 Data Representations 1.1 The Binary System The Binary System is a way of writing numbers using only the digits 0 and 1. This is the method used by the (digital) computer. The system we

More information

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS

UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS UNIT - I: COMPUTER ARITHMETIC, REGISTER TRANSFER LANGUAGE & MICROOPERATIONS (09 periods) Computer Arithmetic: Data Representation, Fixed Point Representation, Floating Point Representation, Addition and

More information

Chapter 4. Operations on Data

Chapter 4. Operations on Data Chapter 4 Operations on Data 1 OBJECTIVES After reading this chapter, the reader should be able to: List the three categories of operations performed on data. Perform unary and binary logic operations

More information

Positional Number System

Positional Number System Positional Number System A number is represented by a string of digits where each digit position has an associated weight. The weight is based on the radix of the number system. Some common radices: Decimal.

More information

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University

Review of Data Representation & Binary Operations Dhananjai M. Rao CSA Department Miami University Review of Data Representation & Binary Operations Dhananjai M. Rao () CSA Department Miami University 1. Introduction In digital computers all data including numbers, characters, and strings are ultimately

More information

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION. Data Representation in Computer Systems

Jones & Bartlett Learning, LLC NOT FOR SALE OR DISTRIBUTION. Data Representation in Computer Systems There are 10 kinds of people in the world those who understand binary and those who don t. Anonymous 2CHAPTER Data Representation in Computer Systems 2.1 INTRODUCTION he organization of any computer depends

More information

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah

NUMBER OPERATIONS. Mahdi Nazm Bojnordi. CS/ECE 3810: Computer Organization. Assistant Professor School of Computing University of Utah NUMBER OPERATIONS Mahdi Nazm Bojnordi Assistant Professor School of Computing University of Utah CS/ECE 3810: Computer Organization Overview Homework 4 is due tonight Verify your uploaded file before the

More information

Computer Architecture and Organization

Computer Architecture and Organization 3-1 Chapter 3 - Arithmetic Computer Architecture and Organization Miles Murdocca and Vincent Heuring Chapter 3 Arithmetic 3-2 Chapter 3 - Arithmetic Chapter Contents 3.1 Fixed Point Addition and Subtraction

More information

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column

Number Systems. Decimal numbers. Binary numbers. Chapter 1 <1> 8's column. 1000's column. 2's column. 4's column 1's column 10's column 100's column 1000's column 1's column 2's column 4's column 8's column Number Systems Decimal numbers 5374 10 = Binary numbers 1101 2 = Chapter 1 1's column 10's column 100's

More information

DIGITAL SYSTEM DESIGN

DIGITAL SYSTEM DESIGN DIGITAL SYSTEM DESIGN UNIT I: Introduction to Number Systems and Boolean Algebra Digital and Analog Basic Concepts, Some history of Digital Systems-Introduction to number systems, Binary numbers, Number

More information