1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

bits 'game'

Discussion in 'Mathematics and Physics' started by electroRF, Jan 10, 2014.

Thread Status:
Not open for further replies.
  1. Ratchit

    Ratchit Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    1,934
    Likes:
    78
    ONLINE
    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: Jan 13, 2014
  2. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    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: http://www.digitalsignallabs.com/fp.pdf
     
    Last edited: Jan 13, 2014
  3. Ratchit

    Ratchit Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    1,934
    Likes:
    78
    ONLINE
    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
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland

    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.
     
  6. NorthGuy

    NorthGuy Well-Known Member

    Joined:
    Sep 8, 2013
    Messages:
    1,218
    Likes:
    206
    Location:
    Northern Canada
    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.
     
    • Agree Agree x 1
  7. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,163
    Likes:
    909
    Location:
    Rochdale UK
    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..
     
Thread Status:
Not open for further replies.

Share This Page