sign magnitude, ones complement, two's complement

Discussion in 'C Programming' started by Mantorok Redgormor, Oct 5, 2003.

  1. From least to greatest is it

    sign magnitude
    ones complement
    two's complement

    Where sign magnitude is the least way to represent integers
    and two's complement is the best way to represent integers?

    What are the pitfalls of them?
     
    Mantorok Redgormor, Oct 5, 2003
    #1
    1. Advertising

  2. "osmium" <> wrote in message
    news:blq4r0$f15nv$-berlin.de...
    > Mantorok Redgormor writes:
    >
    > > sign magnitude
    > > ones complement
    > > two's complement

    >
    > > What are the pitfalls of them?

    >
    > I doubt if sign magnitude has ever been used in a popular US computer.

    The
    > disadvantage of ones complement is that there are two representations for

    0,
    > "positive" zero and negative zero. OTOH subtraction is less onerous with

    a
    > ones complement hardware design.


    I believe the IBM 7090. But then they internally convert to ones complement
    to do addition and subtraction.

    Multiply and divide are easier in sign magnitude, and I believe divide is
    done that way on most computers now.

    > Two's complement is certainly the dominant form in current computers.


    Except for those made by Univac.

    -- glen
     
    Glen Herrmannsfeldt, Oct 6, 2003
    #2
    1. Advertising

  3. Mantorok Redgormor

    osmium Guest

    Mantorok Redgormor writes:

    > sign magnitude
    > ones complement
    > two's complement


    > What are the pitfalls of them?


    I doubt if sign magnitude has ever been used in a popular US computer. The
    disadvantage of ones complement is that there are two representations for 0,
    "positive" zero and negative zero. OTOH subtraction is less onerous with a
    ones complement hardware design.

    Two's complement is certainly the dominant form in current computers.
     
    osmium, Oct 6, 2003
    #3
  4. >From least to greatest is it

    Least to greatest *WHAT*? Number of transistors in the CPU
    to implement it? Tax rate? Weight of the documentation?

    >sign magnitude
    >ones complement
    >two's complement
    >
    >Where sign magnitude is the least way to represent integers
    >and two's complement is the best way to represent integers?


    Which is better, rat poison, a condom, or a Pepsi? It does rather
    depend on what you want it for.

    >What are the pitfalls of them?


    Unless you are designing a CPU or selecting one to buy, you don't
    get to choose, and there are many MANY factors much more important
    than this (like availability of a good compiler for it).

    Gordon L. Burditt
     
    Gordon Burditt, Oct 6, 2003
    #4
  5. Mantorok Redgormor

    osmium Guest

    Glen Herrmannsfeldt writes:

    > > I doubt if sign magnitude has ever been used in a popular US computer.


    > I believe the IBM 7090. But then they internally convert to ones

    complement
    > to do addition and subtraction.


    I'll be damned! And also the 7094 according to this link. Just to cloud
    the issue they use twos complement for some index fiddling if you look at
    the instruction repertoire; which is also on this site.

    http://www.frobenius.com/binary.htm
     
    osmium, Oct 6, 2003
    #5
  6. Mantorok Redgormor

    CBFalconer Guest

    osmium wrote:
    > Mantorok Redgormor writes:
    >
    > > sign magnitude
    > > ones complement
    > > two's complement

    >
    > > What are the pitfalls of them?

    >
    > I doubt if sign magnitude has ever been used in a popular US
    > computer. The disadvantage of ones complement is that there are
    > two representations for 0, "positive" zero and negative zero.
    > OTOH subtraction is less onerous with a ones complement hardware
    > design.
    >
    > Two's complement is certainly the dominant form in current
    > computers.


    Actually arithmetic is more convenient in 2's complement, because
    there is no need for end-around-carries.

    However negation of a value is simpler in 1's complement. By
    making the basic arithmetic operation a subtractor (rather than an
    adder) you can avoid negative zero ever appearing, thus allowing
    use of that value as a trap (e.g. uninitialized).

    --
    Chuck F () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
     
    CBFalconer, Oct 6, 2003
    #6
  7. Mantorok Redgormor

    Eric Sosman Guest

    osmium wrote:
    >
    > Mantorok Redgormor writes:
    >
    > > sign magnitude
    > > ones complement
    > > two's complement

    >
    > > What are the pitfalls of them?

    >
    > I doubt if sign magnitude has ever been used in a popular US computer.


    The first computer I ever programmed used signed magnitude.
    Was it "popular?" Hard to tell, but IBM thought enough of the
    design to build the machines and offer them in a range of sizes
    (twenty, forty, or sixty thousand decimal digits of memory).

    --
     
    Eric Sosman, Oct 6, 2003
    #7
  8. Mantorok Redgormor

    Joe Wright Guest

    Eric Sosman wrote:
    >
    > osmium wrote:
    > >
    > > Mantorok Redgormor writes:
    > >
    > > > sign magnitude
    > > > ones complement
    > > > two's complement

    > >
    > > > What are the pitfalls of them?

    > >
    > > I doubt if sign magnitude has ever been used in a popular US computer.

    >
    > The first computer I ever programmed used signed magnitude.
    > Was it "popular?" Hard to tell, but IBM thought enough of the
    > design to build the machines and offer them in a range of sizes
    > (twenty, forty, or sixty thousand decimal digits of memory).
    >

    Upthread, someone mentioned the last might have been the IBM 7094 which
    came out in Jan 1963 and was the last of the 'Old Iron' before the
    'Modern' IBM 360 and later. How 'popular' could the 7094 have been? How
    many of them were built? I don't know the number. 100? More?

    My first computer was the Philco 2000/212 which came out the same month
    as the 7094. In long suit we had 32K of 48-bit (8-character) words of
    RAM in four 8K banks. Each bank had a cycle time of 1.1 microseconds.
    Bank selection was done in the low order two bits of address so that we
    could get four 48-bit words every 1.1 usecs. This was 'core' memory with
    real magnetic cores.

    We left the 7094 for dead.

    Philco Computers, Willow Grove, PA, R.I.P.
    --
    Joe Wright http://www.jw-wright.com
    "Everything should be made as simple as possible, but not simpler."
    --- Albert Einstein ---
     
    Joe Wright, Oct 7, 2003
    #8
  9. "CBFalconer" <> wrote in message
    news:...
    > osmium wrote:
    > > Mantorok Redgormor writes:
    > >
    > > > sign magnitude
    > > > ones complement
    > > > two's complement

    > >
    > > > What are the pitfalls of them?


    (snip)

    > > Two's complement is certainly the dominant form in current
    > > computers.

    >
    > Actually arithmetic is more convenient in 2's complement, because
    > there is no need for end-around-carries.


    With popular adder designs end-around carry isn't hard to do, and shouldn't
    be slower. It complicates serial adders, but since the PDP-8S I don't know
    that there have been any machines with serial binary adders.

    > However negation of a value is simpler in 1's complement. By
    > making the basic arithmetic operation a subtractor (rather than an
    > adder) you can avoid negative zero ever appearing, thus allowing
    > use of that value as a trap (e.g. uninitialized).


    Yes, negation can be complicated with two's complement, as it can overflow.
    On some machines this means processing a trap or exception for that case.

    -- glen
     
    Glen Herrmannsfeldt, Oct 8, 2003
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sarathy

    1's complement and 2's complement

    sarathy, Aug 1, 2006, in forum: C Programming
    Replies:
    20
    Views:
    2,253
    Bo Persson
    Aug 2, 2006
  2. sarathy
    Replies:
    22
    Views:
    2,410
    Bo Persson
    Aug 2, 2006
  3. yadin
    Replies:
    0
    Views:
    294
    yadin
    Sep 29, 2007
  4. ANN: magnitude 0.9.1

    , Oct 16, 2007, in forum: Python
    Replies:
    10
    Views:
    525
  5. Roberto Waltman

    2's complement vs. 1's complement vs. ...

    Roberto Waltman, Jun 9, 2011, in forum: C Programming
    Replies:
    4
    Views:
    1,423
    Michael Press
    Jun 14, 2011
Loading...

Share This Page