![]() |
signed and unsigned value
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 |
Re: signed and unsigned value
On 2010-01-16, deepak <deepakpjose@gmail.com> 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. |
Re: signed and unsigned value
Andrew Poelstra <apoelstra@localhost.localdomain> writes:
> On 2010-01-16, deepak <deepakpjose@gmail.com> 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) kst-u@mib.org <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" |
Re: signed and unsigned value
On Fri, 15 Jan 2010 18:41:59 -0800 (PST), deepak
<deepakpjose@gmail.com> 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 |
| All times are GMT. The time now is 12:41 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.