Open main menu

CDOT Wiki β

Changes

Signed

359 bytes added, 15:49, 8 September 2014
no edit summary
== Two's Compliment ==
stored in In two's compliment representation, positive integer values are represented by the binary representation of the integer, and negative integer values are represented by the '''two's compliment''' of the absolute integer value -- effectively, (2<sup>'''wordsize'''</sup>-abs('''n''')), where '''width''' is the most significant bit word size, and '''n''' is used as a negative signthe integer being represented.are Signed used values
Example: A single unsigned [[Word#Byte|byte]] (8 bits) stores an integer value in the range of 0 to (2^8 - 1 =) 255. If the byte is treated as a signed value, then values from 0-127 (0x00-0x7F) are treated as the positive integers 0-127, and the values 128-255 (0x80-0xFF) are treated as negative integers -128 to -1.
 
Notice that in two's compliment representation, the highest-order bit is the sign bit: 0 == positive, 1 == negative.
Signed address offsets are often used for relative [[Addressing Mode|addressing modes]].