# The maximum decimal integer that can be stored in memory of 8-bit word processor computer?

Actually i am preparing for an exam and in the last year exam this que. was been asked. i.e

The maximum decimal integer number that can be stored in memory of 8-bit word processor computer ?

a) (128)10
b) (127)10
c) (129)10
d) (255)10

Answer of this que. as given in the answer key is b) 127. And I have no idea how they arrived at this result.

Acc. to my understanding, we have 8-bits, which is 28 = 256 so 255 should be the maximum integer which we can store.

EDIT - An another very similar que. asked in same exam was

The maximum permissible integer in a computer with n-bit word processor and one word per integer is equal to

a) 2 n - 1 - 1
b) 2 n - 1
c) 2 n - 1 + 1
d) 2 n + 1

Its ans. is a) 2 n - 1 - 1 (acc. to official ans. key).

By putting n = 8 from above que. we got the answer 127. But again i am clueless how did they derived this answer too.

• Is the number signed or unsigned (hint) – Brian Tompsett - 汤莱恩 Apr 7 at 10:56
• There is no mention about the signed or unsigned number. The que. is asked in exam as it is given above. No other detail is given. – harry Apr 7 at 11:01
• You can represent up to $256$ distinct values. The actual set of values (and hence its maximum element) depends on your encoding. The question is probably assuming that integers are signed and stored using two's complement. See also this Wikipedia page. – Steven Apr 7 at 11:06
• I added another similar que. asked in the same exam, possibly it can provide more clarification. – harry Apr 7 at 11:38
• That is not a reasonable question IMO. Answer could be b or d depending on signedness which the question apparently neglected to specify. – harold Apr 7 at 11:38

The following is the reasonable verdict, I believe, given no more context, as said by Steven's comment and harold's comment.

The maximum (decimal) integer that can be stored in memory of 8-bit word processor computer depends on the context, that is, whether we are talking about unsigned integers or signed integers.

There are $$2^8$$ (256) different possible values for 8 bits. When unsigned, it has possible values ranging from 0 to 255; when signed, it has -128 to 127.

The natural answer, without no more context, should be $$2^8-1=255$$. We have not seen any computer processor that interprets an 8-bit sequence (in a basic level, just to be safer) as an integer that is more than 255. On the other hand, almost all computer processor today can interpret an 8-bit sequence as an (unsigned) integer as large as 255 . In fact, as said in this nice answer of Kristian H,

Unsigned numbers are one interpretation of a sequence of bits. It is also the simplest, and most used interpretation internally to the CPU because addresses, and op codes are simply bits. Memory / Stack addressing and arithmetic are the foundations of microprocessor, well, processing. Moving up the abstraction pyramid, another frequent interpretation of bits is as a character (ASCII, Unicode, EBCDIC).

Having said the above, let me come to defend the choice of the author of that exam, even though I would NOT phrase the question and answer suite as presented in the question.

The question in the exam was designed to test a student's basic understanding of the representation of numbers in our binary computer processors.

If a student chooses, presumably for some good reason, "b) (127)10", we can be confident that student knows the very basic about the representation of a signed integer by two's complement. One bit out of that 8 bits must be used to represent the sign. Somehow, the range of positive integers is one less than the range of negative integers. So, the maximum signed integer in 8 bits is $$2^{8-1}-1$$. We can be confident that student would know the maximum unsigned integer can be represented in 8 bits could be $$2^8-1=255$$.

However, if a student chooses "d) (255)10", it might be hard to justify that student knows what happens with signed integers. So, if the exam is aimed at checking how much students have learned, choice b) could be appropriate.

So, in the context of an exam, a student would have a better chance to be considered more knowledgeable if choice b) is selected instead of choice d). Or a better chance to gain a better grade.

Once again, let me emphasize harold's verdict, "that is not a reasonable question". Ideally, for the intended choice of b), the question should be "the maximum signed integer that can be stored in memory of 8-bit word processor computer?"

• Long Nguyen's professor believes that signed integer is the default format. That could be a strong and better defense for the exam. However, as @PeterJ says, "there are no defaults at a machine code level, most assemblers I'm aware of are fine with defining a byte value of 255". – John L. Apr 7 at 14:40
• Thanks 'John' for this beautiful answer. I got it. I highly appreciate your efforts behind the answer. It will be more helpful for me if you can please explain the term "one word per integer". It was used at the end of 2nd que. (written in EDIT of original que. ) – harry Apr 7 at 17:15
• Professor is of course completely wrong. The largest integer that can be stored in 8 bits is 255. The largest signed integer is 127. – gnasher729 Apr 7 at 17:56
• @harry, "one word per integer", for "n-bit word", means simply $n$ bits are used to represent an integer. It happens often that multiple words or a fraction of a word may be used to represent an integer. Just in case that you are not aware, please note here the word "word" has a particular meaning. – John L. Apr 7 at 19:08
• @harry, indeed, "one word per integer" in the second que. should be added to the first que. as well for better rigor, since some 8-bit word processors can certainly store an integer as large as $2^{15}-1$ or even much larger in memory, using two or more words. – John L. Apr 7 at 19:20

I got the same question in my technical informatics exam. The right answer was also 127, my professor explained signed integer is the default format, therefore the range would go from -128 to 127. You can display 256 distinct value, but the maximum would still be 127.

• Can we generalize it to 2^ (n - 1) - 1 , for n-bits. – harry Apr 7 at 12:33
• yes, you can. If you are interested, there is a very famous problem with unix en.wikipedia.org/wiki/Year_2038_problem. Unix was initially implemented with a time system based on signed 32-bit Integer, which will result in an overflow in the year 2038. – Long Nguyen Apr 7 at 12:37
• You might want to ask your professor where it's a default, IMO there are no defaults at a machine code level, most assemblers I'm aware of are fine with defining a byte value of 255 and I'm pretty sure the C programming language leaves whether a char is signed or unsigned as implementation specific. – PeterJ Apr 7 at 12:45

With a single 8-bit word, you can represent 256 different, distinct values. However, there is nothing in the first question that restricts you to use only one word, you can use however many words you like. With two words, you can already represent 65536 values, with 42 words, we could already represent every particle in the universe. Therefore, the maximum integer that can be represented is arbitrarily large, or put another way there is no maximum integer.

The second question restricts you to use a single word, but there is still a problem: we now know, we can only represent 256 distinct values, but the question doesn't tell us anything about how those values are encoded. For example, the ISO8859-1 encoding of characters can represent the international generic currency sign (¤) as one of the 256 values, but it cannot represent the Euro sign (€). ISO8859-15 on the other hand, can represent the Euro sign but not the generic currency sign, and neither can represent the Bitcoin currency sign ₿.

The same goes for numbers: with 8 bits and an unsigned unary encoding, I can represent the numbers from 0 to 8. With a signed unary encoding, I can represent the numbers from -7 to +7, including both -0 and +0. With an unsigned unary encoding offset by 42, I can represent the number 42 to 50.

Regardless of whether I use a signed or unsigned, unary, binary, decimal, or some other encoding, I can always represent arbitrarily large numbers by introducing an offset in my encoding.

So, again, also for the second question, it is impossible to give the answer.

To answer the second question, we would need to know the encoding, to answer the first question, we would need to know the encoding and the memory size.