asked 125k views
3 votes
A character representing a digit, n, is stored as an 8-bit ASCII code. It needs to be converted into an 8 bit sign-magnitude representation for the negative numerical value, -n. What is the algorithm for doing this? A) Subtract 00110000 from the ASCII code B) Subtract 00110000 from the ASCII code and add 1000 0000 C) Subtract 00110000 from the ASCII code and add 100 0000 D) Subtract 00110000 from the ASCII code and flip the rightmost bit.

2 Answers

7 votes

Final answer:

The algorithm for converting a character representing a digit, n, stored as an 8-bit ASCII code, into an 8-bit sign-magnitude representation for the negative numerical value, -n, is to subtract 00110000 from the ASCII code and flip the rightmost bit.

Step-by-step explanation:

The algorithm for converting a character representing a digit, n, stored as an 8-bit ASCII code, into an 8-bit sign-magnitude representation for the negative numerical value, -n, is to subtract 00110000 from the ASCII code and flip the rightmost bit.

So, the correct answer is D) Subtract 00110000 from the ASCII code and flip the rightmost bit.

4 votes

The correct algorithm for converting an 8-bit ASCII code representing a digit 'n' into an 8-bit sign-magnitude representation for the negative numerical value, -n, is:

B) Subtract 00110000 from the ASCII code and add 1000 0000

The range of ASCII code for digits 0 through 9 is 00110000 to 00111001.

Subtracting 00110000 from the ASCII code will change 'n' to its negative equivalent, which falls between 00000000 and 00001001.

The sign-magnitude representation is created by adding 10000000, where the leftmost bit indicates the sign (0 for positive, 1 for negative), and the remaining 7 bits indicate the magnitude of the number.

answered
User VulfCompressor
by
8.5k points