# How many number systems are there

### Number systems

Every number system consists of nominal values. The number of nominal values ​​results from the base.
The largest face value is the base minus (-) 1.
If the highest nominal value is exceeded, the next higher value arises from the carryover.

#### Decimal number system

Nominal values: 0 1 2 3 4 5 6 7 8 9
Base: 10 Largest face value: 9
Place values: 100 = 1, 101 = 10, 102 = 100, etc., so the sequence of digits means 2731
2*103 + 7*102 + 3*101 + 1*100 = 2000 + 700 + 30 + 1 = 273110.

#### Dual number system

Nominal values: 0 1
Base: 2 Largest face value: 1
Place values: 20 = 1, 21 = 2, 22 = 4, etc., so the sequence of digits 110101 means
1*25 + 1*24 + 0*23 + 1*22 + 0*21 + 1*20 = 32 + 16 + 4 + 1 = 5310.
Exercise: Which decimal value is behind 101010102 ?

Nominal values: 0 1 2 3 4 5 6 7 8 9 A B C D E F
Base: 16 Largest face value: F
Place values: 160 = 1, 161 = 16, 162 = 256, etc., etc., so the sequence of digits 2AF7 means
2*163 + 10*162 + 15*161 + 7*160 = 8192 + 2560 + 240 + 7 =1099910.
Exercise: What is the decimal value behind ABBA16 ?

### Overview: nominal value assignment

1000
2111
32210
43311
544100
655101
766110
877111
9881000
10991001
11A.101010
12B.111011
13C.121100
14D.131101
15E.141110
16F.151111

Conversion between dual system and hexadecimal system

Converting binary numbers to hexadecimal numbers is very easy, since 16 is a power of two.
Example: Let there be an integer with one byte (= 8 bits):

 1 0 1 1 1 0 0 1 (= 18510)

Since the numbers from 0 to 15 can be represented with four bits, 4 bits correspond in the dual system
a digit in the hexadecimal system. A 4-bit group (half a byte) is also called a "nibble".

Exercise: Convert ABBA16 in the Dual system around!

### Calculating in the dual system

The addition in the dual system works like in any other number system:
It is added in places from the last digit.
If the sum is greater than or equal to the number base in one place,
the "remainder" is entered and a carry-over is noted:

1 0 1 1 0
+    1 0 1 1
1 <= Transfers
-----------
1 0 0 0 0 1

The subtraction works accordingly, of course.
There is, however, another interesting possibility that we can look to
Number representation in the calculator leads :

Negative numbers come with a leading 1 represented as a sign bit and coded as follows:
All digits of the corresponding positive number are negated, i.e. 0 becomes 1 and 1 becomes 0.
1 is added to the result. (This representation is called the two's complement.)

Exemplary conversion of the negative decimal number -4 into two's complement for an 8-bit coding:

1. Ignore the sign and convert it into the binary system: 410 = 000001002
2. Invert, since negative: 11111011
3. Add one because it is negative: 11111011 + 00000001 = 11111100, which means "-4".

Since it is well known that a subtraction can also be replaced by the addition of the negative value,
There is a possibility here of performing subtractions with an adder.
More on that later (full adder).

Addition and subtraction do not require any case distinction. The subtraction is reduced to an addition.

Examples of 8-bit numbers without sign extension:

-4 + 3 = -1 leads to 11111100 + 00000011
= 11111111;
+4 +(- 4) = 0:
00000100
+ 11111100
---------
= 100000000

The first one, in this example the 9th digit, is discarded.

+4 - 3 = +1 leads to -4 - 3 = -7 leads to 00000100 11111100 + 11111101 + 11111101 = 100000001 = 111111001

Here, too, the correct result is generated by omitting the 9th digit, in these cases 1.

Examples of binary and hexadecimal representations of negative numbers:

+127(10) = 01111111(2) = 7F(16) + 4(10) = 00000100(2) = 04(16) + 1(10) = 00000001(2) = 01(16) 0(10) = 00000000(2) = 00(16) - 1(10) = 11111111(2) = FF(16) - 4(10) = 11111100(2) = FC(16) -127(10) = 10000001(2) = 81(16) -128(10) = 10000000(2) = 80(16)

As long as the valid n-digit number range, for 8-bit numbers the value range of the sum from -128 to +127,
is not exited, this procedure without sign extension works without any problems.
If, on the other hand, the value range of the sum is outside the interval, an overflow occurs, which
in this context it is often and incorrectly confused with the carryover