Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help but show step by step please very slowly Two positive integers add u

ID: 1846163 • Letter: P

Question

Please help but show step by step please very slowly

Two positive integers add up to negative or two negative integers add up to positive You know signed 8 bits range from -128 to +127 and unsigned 8 bits range from 0 to 255.When you add up 120 + 120, you get 240 or -16. This case you get an overflow of two positive integers add to a negative integer -16.

(a) Overflow: Suppose we have signed 8 bit numbers and consider adding decimal 40 several times, 40, 40 + 40, 40 + 40 + 40, 40 + 40 + 40 + 40, until 40 + 40 + 40 + 40 + 40 + 40 (40*6 literally). We do not go further since 40 + 40 +

Explanation / Answer

Overflow: When any arithmatic operation is performed on signed operands it is sometimes difficult to find the signedness of the result just by checking at sign bit(usually the MSB). In these situations we use the overflow flag to check if there is any sign bit overlfow.
Hence when you add 40 for 3 times you get 120 which is valid for 8 bit signed value. If you add one more time 40 the result is 160(unsigned, -96 signed) but the result is positive and hence the overflow flag is set.

160 in hex is 0xA0 = 0x10100000 in binary. So if the number is considered as singned number then the it becomes (-128)*1+64*0 + 32*2 + 16*0 + 8*0 + 4*0 + 2*0 +1*0 = -96 by converting the signed binary to decimal. So adding 40 to 120 the addition value exceeds 127 and overlaps the bit causing to overflow.

Inital value: 40 -> 0x28 (hex) -> 0x00101000 -> sign bit is zero and not altered -> Overflow is 0

Adding 40:    80 -> 0x50 (hex) -> 0x01010000 -> sign bit is zero and not altered -> Overflow is 0

Adding 40:   120 -> 0x78 (hex) -> 0x01111000 -> sign bit is zero and not altered -> Overflow is 0

Adding 40:   160 -> 0xA0 (hex) -> 0x10100000 -> sign bit is one and altered due to addition -> Overflow is 1

Carry: When any arithmatic operation is performed on unsigned operands, the value of the result may somtimes go out of bounds, that is the result more than 8 bits. In this case carry flag is set.
If you add 40 for 6 times then result is 240.if you add one more time 40 the result is 280, but the result register cannot hold the result. Hence the result resgister will have 24 and the carry bit is set along.

If you add 40 to 240 the result is 280, which has hex value of 0x124 exceeding the maximum value in 8 bits and causing the carry falg to set.

Inital value: 40 -> 0x28 (hex) -> 0x00101000 -> result is contained in 8 bits -> Carry is 0

Adding 40:    80 -> 0x50 (hex) -> 0x01010000 -> result is contained in 8 bits -> Carry is 0

Adding 40: 120 -> 0x78 (hex) -> 0x01111000 -> result is contained in 8 bits -> Carry is 0

Adding 40:  160 -> 0xA0 (hex) -> 0x10100000 -> result is contained in 8 bits -> Carry is 0

Adding 40:  200 -> 0xC8 (hex) -> 0x11001000 -> result is contained in 8 bits -> Carry is 0

Adding 40:  240 -> 0xF0 (hex) -> 0x11110000 -> result is contained in 8 bits -> Carry is 0

Adding 40:  280 -> 0x124 (hex) -> 0x000111001000 -> result is not contained in 8 bits -> Carry is 1

Checksum: it is the unique number generated by the checksum formula(or algorithm) using the bits present in the number. Generally used to detect errors in the data.
Most basic checksum algorithm is the parity check(even parity is 1). for 40(0x28 hex) the parity(chekcsum) is 1 and for 41(0x29 hex) the parity(checksum) is 0.

Parity(even parity is 1): if the number of ones in the binary notation of the number is even then the parity is set to be 1 and if the number of ones is odd then the parity is set to be 0.

Please let me know if you need more clarification.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote