signed and unsigned value

D

deepak

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
 
A

Andrew Poelstra

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.
 
K

Keith Thompson

Andrew Poelstra said:
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.
 
B

Barry Schwarz

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top