Etimreck.files.wordpress.com



Exercise 3.1???? A?????? ?Ba.)?? 3174??? 0522b.)?? 4165??? 16543.1.1 What is the sum of A and B if they represent unsigned 12-bit octal numbers? The result should be written in octal. Show your work.a.) First is to convert the octal numbers base 8?into binary numbers.?????????????????????????????? A???????????????????????????????? B31740522011001111100000101010010So in Binary A: 011 001 111 100two and B: is 000 101 010 010twoA011001111100+B000101010010=011111001110The binary sum of A and B is 011 111 001 110two, in octal it is 3716.b.) We’ll do the same thing as in a)??????????????????????????????? A?????????????????????????????? B41651654100001110101001110101100So the binary representation of A: 100 001 110 101two and B: 001 110 101 100two.A100001110101+B001110101100=110000100001The binary sum of A and B is 110 000 100 001two, in octal it is 6041.To check this and every problem I just used the calculator on my computer and set it to programmer.3.1.2 What is the sum of A and B if they represent signed 12-bit octal numbers stored in sign-magnitude format? The result should be written in octal. Show your work.“In?computer science, the?sign bit?is a?bit?in a?signed number representation?that indicates the?sign?of a number. Only?signed?numeric data types have a sign bit, and its place is usually the leftmost, where the?most significant bit?in unsigned numbers resides.?Floating point?numbers in?IEEE format?are always signed, with the sign bit in the leftmost position. Typically if the sign bit is 1 then the number is?negative?(in the case of?two’s complement?integers) or non-positive (for?ones’ complement?integers,?sign-and-magnitude?integers, and floating point numbers), while 0 indicates a non-negative number” ().We are going to convert the octal numbers into binary as in 3.1.1a.)?????????????????????????????? A???????????????????????????????? B31740522011001111100000101010010Since the most significant bit is 0 for both A and B, we get the same value for signed numbers. The binary representation of A: 011 001 111 100two and B: 000 101 010 010two.A011001111100+B000101010010=011111001110The binary sum of A and B is 011 111 001 110two, in octal it is 3716.b.) We’ll start off the same way as above by converting the octal into binary.??????????????????????????????? A?????????????????????????????? B41651654100001110101001110101100In?A the most significant bit is 1, so it is negative. Leave the most significant bit which is the 1, which leaves you with:00001110101Now you want to take the 2′s complement, simply switch every 0 to 1 and every 1 to 0, and add one to the result. You will get:A’211110001010Take that and add 1 to it:11110001010 +111110001011B is the same as before, since the number is positive.?????????????????????????????????B1654001110101100The binary representation of A is 11 110 001 011two, and B is 001 110 101 100two. The sum of A and B is:A’211110001011+B001110101100=0110011011101 100 110 111two = 1467 octal.3.1.4 What is A – B if they represent unsigned 12-bit octal numbers? The result should be written in octal. Show your work.ABa.)70400444b.)43653412a.)?? The first step is the same as 3.1.1 and 3.1.2, convert to binary:??????????????????????????????? A??????????????????????????????? B70400444111000100000000100100100A – B:A111000100000-B000100100100=110011111100 110 011 111 100two, which is 6374 octal.b.) Again convert the octal into binary:???????????????????????????????? A???????????????????????????????? B43653412100011110101011100001010A – B:A110011110101-B011100001010=000111101011= 000 111 101 011_two, which is 0753 octal.3.1.5 What is A- B if they represent signed 12-bit octal numbers stored in sign-magnitude format? The result should be written in octal. Show your work.a.) Since?A is negative you are going to do steps similar to problem 3.1.2, drop the most significant bit giving you 11 000 100 000two, then take the 2′s complement (simply switch every 0 to 1 and every 1 to 0) and then add one to the result. The table below shows the steps:????????????????????????????? A7040111000100000??????????? Drop the most ? significant bit11000100000??????????????????? Switch 0′s and 1′s00111011111??????????????????? 2′s complement00111100000B is the same as before, since the number is positive.B0444000100100100Now do A – B:A00111100000-B000100100100=0001011110000 010 111 100two is 0274 octal.b.) Since?A is negative you are going to do steps similar to problem 3.1.2, drop the most significant bit giving you 00 011 110 101two, then take the 2′s complement (simply switch every 0 to 1 and every 1 to 0) and then add one to the result. The table below shows the steps:?????????????????????????????? A4365100011110101Drop the most ? significant bit00011110101Switch 0′s and 1′s111000010102′s complement11100001011B is the same as before, since the number is positive.??????????????????????????????? B3412011100001010A – BA11100001011-B011100001010=0000000000100 000 000 001two is 0001 octal.Exercise 3.2ABa.1446672Fb.246049353.2.1 What is the sum of A and B if they represent unsigned 16-bit hexadecimal numbers? The result should be written in hexadecimal. Show your work.Since the left most bit is the sign bit in the binary number, then the following rule can be used with any binary number in order to figure out either it is a positive number, or a negative number: 1)If the most left bit is 0, and then the binary number is a positive number. 2) If the most left bit is 1, then the binary number is a negative number.“Hexadecimal is a positional numeral system with a radix, or base, of 16. It uses sixteen distinct symbols, most often the symbols 0–9 to represent values zero to nine, and A,?B,?C,?D,?E,?F (or alternatively a–f) to represent values ten to fifteen.” ()a.) The first step is to convert from hexadecimal to binary.???????????????????????????????? A??????????????????????????????? B1446672F00010100010001100110011100101111A + BA0001010001000110+B0110011100101111=0111101101110101Now you want to convert 0111 1011 0111 0101 back into hexadecimal.01111011011101017B75A + B = 7B75b.) Again convert the hexadecimal numbers into binary.???????????????????????????????? A??????????????????????????? B2460493500100100011000000100100100110101A + BA0010010001100000+B0100100100110101=0110110110010101Now take 0110 1101 1001 0101 and convert it back into hexadecimal.01101101100101016D95A + B = 6D953.2.2 What is the sum of A and B if they represent signed 16-bit hexadecimal numbers stored in sign-magnitude format? The result should be written in hexadecimal. Show your workABa.1446672Fb.24604935a.)The first step is to convert from hexadecimal to binary.???????????????????????????????? A??????????????????????????????? B1446672F00010100010001100110011100101111Both A and B have zero at the most left bit, so they are positive numbers. Since both A and? B are positive numbers, then the sum of A+B in singed 12-bits will be similar in unsigned?16?-bits.A in binary0001010001000110B0110011100101111A+B (binary)0111101101110101A+B = 7b75b.)The first step is to convert from hexadecimal to binary.???????????????????????????????? A??????????????????????????????? B2460493500100100011000000100100100110101Both A and B have zero at the most left bit, so they are positive numbers. Since both A and? B are positive numbers, then the sum of A+B in singed 12-bits will be similar in unsigned?16?-bits.A in binary0010010001100000B0100100100110101A+B (binary)0110110110010101A+B= 6d953.2.3 Convert A into a decimal number, assuming it is unsigned.Repeat assuming it stored in sign-magnitude format. Show your work.Aa.1446b.2460Unsigned Format:a.) The value of A which is 1446 (base 16) that can be represented in a binary form (base 2) byA 14460001010001000110then converting the binary number to decimal number:(0* 2^0)?+?(1* 2^1)+(1* 2^2)+(0* 2^3)+(0* 2^4)+(0* 2^5)+(1* 2^6)+(0* 2^7)+(0* 2^8)+(0* 2^9)+(1* 2^10)+(0* 2^11) +(1* 2^12)+(0* 2^13)+(0* 2^14)+(0* 2^15)?= 2+4+64+1024++4096 =?5190 (base 10).b.)The value of A is 2460 (base 16) which can be represented in a binary form (base 2) byA 24600010010001100000(0* 2^0)?+?(0* 2^1)+(0* 2^2)+(0* 2^3)+(0* 2^4)+(1* 2^5)+(1* 2^6)+(0* 2^7)+(0* 2^8)+(0* 2^9)+(1* 2^10)+(0* 2^11)+(0* 2^12)+(1* 2^13)+(0* 2^14)+(0* 2^15)??= 32+64+1024+8192 = 9312 (base 10).Sign-Magnitude Format:a.)The value of A which is 1446 (base 16) that can be represented in a binary form (base 2) byA 14460001010001000110then converting the binary number to decimal number by ?the following way:(0* 2^0)?+?(1* 2^1)+(1* 2^2)+(0* 2^3)+(0* 2^4)+(0* 2^5)+(1* 2^6)+(0* 2^7)+(0* 2^8)+(0* 2^9)+(1* 2^10)+(0* 2^11) +(1* 2^12)+(0* 2^13)+(0* 2^14)+(0*(- 2^15))?= 2+4+64+1024++4096?=?5190 (base 10).b.)The value of A is 2460 (base 16) which can be represented in a binary form (base 2) byA 24600010010001100000(0* 2^0)?+?(0* 2^1)+(0* 2^2)+(0* 2^3)+(0* 2^4)+(1* 2^5)+(1* 2^6)+(0* 2^7)+(0* 2^8)+(0* 2^9)+(1* 2^10)+(0* 2^11)+(0* 2^12)+(1* 2^13)+(0* 2^14)+(0* *(-2^15))??= 32+64+1024+8192 = 9312 (base 10).3.2.4 What is A – B if they represent unsigned 16-bit hexadecimal numbers? The result should be written in hexadecimal. Show your work.ABa.C35236AEb.5ED407A4a.) The first step is to convert from hexadecimal to binary. Then subtract A to BA C352B?36AE1100001101010010001101101010111011000011010100100011011010101110A-B =1000110010100100A-B= 8CA4b.) The first step is to convert from hexadecimal to binary. Then subtract A to BA 5ED4B?07A40101111011010100000001111010010001011110110101000000011110100100A-B =0101011100110000A-B=57303.2.5 What is A – B if they represent signed 16-bit hexadecimal?numbers stored in sign-magnitude format? The result should be written in hexadecimal. Show your work.ABa.C35236AEb.5ED407A4a.) The first step is to convert from hexadecimal to binaryA C352B36AE11000011010100100011011010101110Since?A is negative you are going to take the 2′s complement (simply switch every 0 to 1 and every 1 to 0) and then add one to the result0011110010101101 +10011110010101110B is the same as before, since the number is positive.A 0011110010101110-B0011011010101110A-B =0000011000000000A-B=0600b.) The first step is to convert from hexadecimal to binaryA 5ED4B07A4?01011110110101000000011110100100Both A and B have zero at the most left bit, so they are positive numbers. Since both A and? B are positive numbers, then the sum of A-B in singed 12-bits will be similar in unsigned?16?-bits.A 0101111011010100-B0000011110100100A-B =0101011100110000A-B= 57303.2.6 ?Convert A into a binary number. What makes base 16 (hexadecimal) an attractive numbering system for representing values in computers?Aa.C352b.5ED4a.)The value of A which is?C352?(base 16) that can be represented in a binary form (base 2) byA C3521100001101010010then converting the binary number to decimal number:(0* 2^0)?+?(1* 2^1)+(0* 2^2)+(0* 2^3)+(1* 2^4)+(0* 2^5)+(1* 2^6)+(0* 2^7)+(1* 2^8)+(1* 2^9)+(0* 2^10)+(0* 2^11) +(0* 2^12)+(0* 2^13)+(1* 2^14)+(1* 2^15)?= 50002(base 10).b.)The value of A is?5ED4??(base 16) which can be represented in a binary form (base 2) byA 5ED40101111011010100(0* 2^0)?+?(0* 2^1)+(1* 2^2)+(0* 2^3)+(1* 2^4)+(0* 2^5)+(1* 2^6)+(1* 2^7)+(0* 2^8)+(1* 2^9)+(1* 2^10)+(1* 2^11)+(1* 2^12)+(0* 2^13)+(1* 2^14)+(0* 2^15)??= 4+16+64+128+512+1024+2048+4096+16384 = 24276(base 10).Exercise 3.3Overflow occurs when a result is too large to be represented accurately given afinite word size. Underflow occurs when a number is too small to be representedcorrectly—a negative result when doing unsigned arithmetic, for example. (Thecase when a positive result is generated by the addition of two negative integers isalso referred to as underflow by many, but in this textbook, that is considered anoverflow.) The following table shows pairs of decimal numbers.? ?ABa.216255b.1851223.3.1 ?Assume A and B are unsigned 8-bit decimal integers. CalculateA – B. Is there overflow, underflow, or neither?a.) The first step is to convert from decimal to binary, then subtract A 216B 255110110001111111A11011000-B1111111=1100111"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow by many, but in this textbook, that is considered an overflow.?"? (given by the book) There is underflowb.) The first step is to convert from decimal to binary, then subtractA 185B 122101110011111010A10111001-B1111010=00111111"Underflow occurs when a number is too small to be representedcorrectly—a negative result when doing unsigned arithmetic, for example. (Thecase when a positive result is generated by the addition of two negative integers isalso referred to as underflow??"? ? (given by the book)There is underflow, but in this textbook, it is considered as an overflow. Because two negative numbers give a positive number.3.3.2 Assume A and B are signed 8-bit decimal integers stored in sign magnitudeformat. Calculate A + B. Is there overflow, underflow, or neither?ABa.216255b.185122a.) The first step is to convert from decimal to binary, then Add A to B A 216B 255110110001111111A11011000+B1111111=101010111"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow by many, but in this textbook, that is considered an overflow.?" (given by the book) There is underflowb.) The first step is to convert from decimal to binary, then subtractA 185B 1221011100101111010A10111001-B01111010=100110011?"Underflow occurs when a number is too small to be representedcorrectly—a negative result when doing unsigned arithmetic, for example. (Thecase when a positive result is generated by the addition of two negative integers isalso referred to as underflow??"? ? (given by the book)There is overflow3.3.3 Assume A and B are signed 8-bit decimal integers stored in sign magnitudeformat. Calculate A – B. Is there overflow, underflow, or neither?ABa.216255b.185122a.) The first step is to convert from decimal to binary, then Add A to B A 216B 2551101100001111111A11011000-B01111111=101010111"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow by many, but in this textbook, that is considered an overflow.?”(given by the book) There is neither?overflow, nor underflowb.) The first step is to convert from decimal to binary, then subtractA 185B 1221011100101111010A10111001-B01111010=00111111"Underflow occurs when a number is too small to be representedcorrectly—a negative result when doing unsigned arithmetic, for example. (Thecase when a positive result is generated by the addition of two negative integers isalso referred to as underflow??"? ? (given by the book)There is neither?overflow, nor underflow3.3.4 ?Assume A and B are signed 8-bit decimal integers stored intwo’s complement format. Calculate A + B using saturating arithmetic. The resultshould be written in decimal. Show your work.ABa.15139b.151214a.) The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1, A 15B 13900001111100010112’s complement1111000001110100+ 11111000101110101Then A + BA 11110001+B01110101=01100110"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow" (given by the book)There is neither?overflow, nor underflowb.)?The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1, A 151B 21410010111110101102’s complement0110100000101001+ 10110100100101010Then A + BA 01101001+B00101010=10010010"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow?"(given by the book)There is overflow because the sum of two positive numbers gives a negative number.3.3.5 Assume A and B are signed 8-bit decimal integers stored intwo’s complement format. Calculate A – B using saturating arithmetic. The resultshould be written in decimal. Show your work.a.) The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1, A 15B 13900001111100010112’s complement1111000001110100+ 11111000101110101Then A - BA 11110001-B01110101=01111100"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow" (given by the book)There is overflowb.)?The first step is to convert from decimal to binary, Then take the 2’s complement and Add 1, A 151B 21410010111110101102’s complement0110100000101001+ 10110100100101010Then A - BA 01101001-B00101010=00111110"Underflow occurs when a number is too small to be represented correctly—a negative result when doing unsigned arithmetic, for example. (The case when a positive result is generated by the addition of two negative integers is also referred to as underflow?"(given by the book)There is underflow? ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download