signed and unsigned value

Discussion in 'C Programming' started by deepak, Jan 16, 2010.

  1. deepak

    deepak Guest

    Hi,

    Could some one tell how signed and unsigned value considered in CPU.
    Will they check most significant bit based on type of variable and
    process
    one way if it's signed and other way if it's unsigned variable.

    Thanks,
    Deepak
    deepak, Jan 16, 2010
    #1
    1. Advertising

  2. On 2010-01-16, deepak <> wrote:
    > Hi,
    >
    > Could some one tell how signed and unsigned value considered in CPU.
    > Will they check most significant bit based on type of variable and
    > process
    > one way if it's signed and other way if it's unsigned variable.
    >


    Lookup the term 'endianness' for bit ordering.
    For signedness, try
    2's complement
    1's complement
    signed magnitude

    Wiki is your friend.

    But neither of these questions are related to C.
    Andrew Poelstra, Jan 16, 2010
    #2
    1. Advertising

  3. Andrew Poelstra <> writes:
    > On 2010-01-16, deepak <> wrote:
    >> Could some one tell how signed and unsigned value considered in CPU.
    >> Will they check most significant bit based on type of variable and
    >> process
    >> one way if it's signed and other way if it's unsigned variable.

    >
    > Lookup the term 'endianness' for bit ordering.
    > For signedness, try
    > 2's complement
    > 1's complement
    > signed magnitude
    >
    > Wiki is your friend.
    >
    > But neither of these questions are related to C.


    Well, actually they are. The C standard (as of C99) specifies that
    signed integers must use one the above three representations.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Nokia
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jan 16, 2010
    #3
  4. On Fri, 15 Jan 2010 18:41:59 -0800 (PST), deepak
    <> wrote:

    >Hi,
    >
    >Could some one tell how signed and unsigned value considered in CPU.
    >Will they check most significant bit based on type of variable and
    >process
    >one way if it's signed and other way if it's unsigned variable.


    It would be unlikely that your approach could detect the difference
    between a positive value stored in a signed object and the same value
    stored in an unsigned object.

    As far as the language is concerned, this is not a CPU issue. Whether
    the CPU can deal with signed and unsigned distinctly (such as IBM
    mainframes) or whether it can only deal with one type or the other, it
    is always the compiler's job to generate the appropriate set of
    instructions so that the result of the computation complies with the
    standard.

    --
    Remove del for email
    Barry Schwarz, Jan 31, 2010
    #4
    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. me2

    hex and unsigned and signed decimal

    me2, Dec 28, 2006, in forum: C Programming
    Replies:
    14
    Views:
    1,572
    Keith Thompson
    Jan 2, 2007
  2. kyrpa83
    Replies:
    1
    Views:
    612
    kyrpa83
    Oct 17, 2007
  3. Replies:
    3
    Views:
    400
    James Kanze
    Nov 19, 2008
  4. Replies:
    5
    Views:
    1,863
  5. pozz
    Replies:
    12
    Views:
    716
    Tim Rentsch
    Mar 20, 2011
Loading...

Share This Page