bits 'game'

Status
Not open for further replies.
Not a very good academic analysis because you are not using the whole range that 8-bits can represent.

Academics have nothing to do with this problem. I start out with the highest positive 8-bit signed number of 127 or 7Fh. Then I subtract -128 or 80h and get an overflow right away. So I switch to a 9 bit word. Now there is an ambiguity with the problem statement. Do I use the same 8-bit values or new 9-bit values? NorthGuy and I appear to use the old 8-bit values, and determined we need 12 bits to represent the expression. The other option is to use what the values of the 9-bit register will be. I will let you do that problem if you want.

Ratch
 
Last edited:
I'm wondering what would be a 'neat' way to solve it?

You could follow these rules:

1) The sum of two M-bit numbers requires M+1 bits (+ sign bit)
2) The multiplication of two M-bit unsigned numbers requires 2M bits
3) The multiplication of two M-bit signed numbers requires 2M+1 bits (+ sign bit)
4) Unsigned division requires M bits
5) Signed division requires M+1 bits (+ sign bit)

The bitcount M does not include the sign bit for signed integers.

More theory: **broken link removed**
 
Last edited:

Those are not really rules, they are requirements for different arithmetical operations for "fixed" register operations. There is nothing in that link that I don't know or can discern if necessary. The problem is ambiguous as I pointed out before, and the link will not help with that.

Ratch
 
Those are not really rules, they are requirements..
Rules, requirements.. whatever. You just can't help trolling.
My post was not meant to argue with something you said. Just give EF some rules he can follow to solve the problem more analytically (independently from any fixed bitlength). And to point out theory that is relevant to the original question.
 
You can use 8 bits to store anything - numbers, bit flags, characters. It's up to you to make sure your presentation is what you need.

The OP talks about integer variables which represent numbers. So, we need to talk about representing numbers. The goal is to make sure that our computer programming preserves the abstract mathematical numbers.

8-bit signed integers represent numbers from -128 to 127. If you subtract two arbitrary variables of this kind, the result can be anything from -256 to 254. To store all possible number in a variable, you need at least 9-bit signed variable.

8-bit unsigned integers represent numbers from 0 to 255. If you subtract two arbitrary variables of this kind, the result can be anything from -255 to 255. To store all possible number in a variable, you need at least 9-bit signed variable.

If first is unsigned and second signed, the range is -128 to 382. Now you need 10-bit signed variable.

If first is signed and second unsigned, the range is -383 to 127. You need a 10-bit signed variable again.

See that. Regardless of wether the original variables were signed or unsigned, the result requires a signed variable.
 
I see no point in continuing this thread.... The OP hasn't responded since Saturday!!!

All I see is a debate that'll never end..
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…