Data and computer

    The elementary data unit is bit, a short for binary digit. In fact it's a one-cipher binary number, so a bit has two states: 0 and 1. These are sometimes considered as "false" (there is no current) or "true" (there is a current).

    But the basic data unit is byte, whose length is eight bits. So it can contain 28 various numbers, which are used to be considered as decimal numbers (0..255), but you can use also hexadecimal form (000h..0FFh, ciphers used in hexadecimal numbers are 0123456789ABCDEF) or binary form (00000000b..11111111b). Like all numbers also these are put down beginning with the "highest" (most significant) cipher (100 for decimal numbers,16 for hexadecimal and 128 for binary) and ending with the "lowest" cipher (In all cases 1). All data in computer are coded in bytes like these or like a group of bytes. A group of two bytes is called "word".

    Work with binary numbers is similar to work with decimal numbers.

Adding example:
 10100110 (166)
+00010101 (021)
---------------
 10111011 (187)

Subtraction example:
 10100110 (166)
-00010101 (021)
---------------
 10010001 (145)

    There was a need to work with negative numbers so there had to be a possibility to put down the sign of the number. How? Try to subtract one from zero. The result will be 255 - logically, it's so called underflow (as the opposite to overflow, which can occur e.g. in addition). And how looks this number? -1=11111111b. So -2=11111110b. According to the standard the sing of a number is indicated by the highest (first) bit of the data unit. So if we want to use a byte for a number with sign, we can store numbers from -128 (10000000b, 80h) trough zero to 127 (01111111b, 7Fh) instead of original from 0 to 255, using two bytes - a word - we can store numbers from -32768 (1000000000000000b, 8000h) through zero to 32767 (0111111111111111b, 7FFFh) instead of original from 0 to 65535.

    If we try to compute those two examples now, when we can consider them as numbers with sign, we will find out that they apply even now:

 10100110 (-90)
+00010101 (+21)
---------------
 10111011 (-69)

 10100110 (-90)
-00010101 (+21)
---------------
 10010001 (-111)

    In the next text, if I won't mention something else, I will use numbers without sign.