top decor
Basics Signed an unsigned information


When bytes, wydes, tetras and octas represent numbers, they can be signed or unsigned. In the last case the most significant bit stores the sign of the number: 0 codes plus and 1 - minus.

Negative numbers are stored in memory in a special way called complement code. To get this code for negative integer do the following:

  • in absolute value of the binary number change every digit to the opposite: 0 to 1 and 1 to 0
  • add 1 to the result
Such manner of coding provides the easement of arithmetic operations inside a computer.

Example
Let's convert -127 into complement code:
12710 =0111 11112
invert:1000 0000
add 1:1000 00012 = 8116
The coding of several characteristic numbers is shown in the table below.

contents of byte (hex) 0001... 7F8081... FEFF
unsigned number (decimal) 01... 127128129... 254255
signed number (decimal) 01... 127-128-127... -2-1

You can see that an unsigned byte is a number between 0 and 28 - 1 = 255 inclusive. A signed integer lies between -128 and +127 inclusive.

Similar situation takes place for wydes, tetras and octas.

unitsizeminimum / maximum
 (bits) unsigned signed
byte 8028 - 1 = 255 -128127
wyde 160216 - 1 = 65 535 -32 76832 767
tetra 320232 - 1 = 4,294,967,295 -2,147,483,6482,147,483,647
octa 640264 - 1 =
18,446,744,073,709,551,615
-9,223,372,036,854,775,8089,223,372,036,854,775,807


Related topics:

"MMIX basics" page
 

  (C) 2001, Evgeny Eremin. rEd-MMI project documentation
1