Monday, December 21, 2009

What system does a computer use to distinguish between positive and negative numbers when stored in memory?

Must electronic devices that deal with negative numbers have a bit place that indicates when the number is positive or negative.





So in the case where a computer uses a 32 bit word, only 31 bits can be used to indicate the value of the number and the other bit is a sign bit.





So 0 in the sign bit location might indicate a negative number and 1 in this location might mean the number is positive.





This is the simplist method, but computers also use the Ones' complement method, Two's complement , Excess-N and Base 鈭? methods. These are all just variations on what I have discribed.





You can read about them here; http://en.wikipedia.org/wiki/One's_compl鈥?/a>What system does a computer use to distinguish between positive and negative numbers when stored in memory?
twos complement eg the msb of a word is used a the signed bit to distinguish +- numbers





FFFFh = -1


0000h = 0


7FFFh =32767 max +ve value in a 16 bit word


8000h =-32768 max -ve value in a 16 bit wordWhat system does a computer use to distinguish between positive and negative numbers when stored in memory?
There are various ways of storing numbers, especially between real numbers and integers. Number types that can be positive or negative use one bit of memory to store the sign, + or -.
they are all just a set of 1s and 0s. the computer can translate those numbers into whatever the program its using tells it to.

No comments:

Post a Comment