Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
introduction_to_digital_systems:number_systems [2023/03/27 10:47] mexleadmin |
introduction_to_digital_systems:number_systems [2023/11/16 01:09] (aktuell) mexleadmin |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== 2. Number Systems ====== | + | ====== 2 Number Systems ====== |
===== 2.1 Types of Number Systems ===== | ===== 2.1 Types of Number Systems ===== | ||
Zeile 28: | Zeile 28: | ||
Besides this representation of quantities also the position of the symbol in the **numeral** was important: | Besides this representation of quantities also the position of the symbol in the **numeral** was important: | ||
- | * In general: the letters have to be arranged decreasing from left to right. For example $MDCI = 1601$ | + | * In general: the letters have to be arranged decreasing from left to right. For example $\rm MDCI = 1601$ |
* There are deviations of this rule: When up to three of the lower symbols are written to the left, these have to be subtracted. Sounds complicated? | * There are deviations of this rule: When up to three of the lower symbols are written to the left, these have to be subtracted. Sounds complicated? | ||
Zeile 151: | Zeile 151: | ||
As an example the Byte4 shall be written in decimal: | As an example the Byte4 shall be written in decimal: | ||
- | $ Z_{10}(Byte4)= Z_{10}(19_{16}) \\ =\sum_{i=0}^1 z_i \cdot 16^i = \\ 1 \cdot 16^1 + 9 \cdot 16^0 = 16 + 9 = 25_{10}$ | + | $ Z_{10}({\rm Byte}4)= Z_{10}(19_{16}) \\ =\sum_{i=0}^1 z_i \cdot 16^i = \\ 1 \cdot 16^1 + 9 \cdot 16^0 = 16 + 9 = 25_{10}$ |
=== Octal === | === Octal === | ||
Zeile 200: | Zeile 200: | ||
^each position in decimal | ^each position in decimal | ||
- | |each position in hexadecimal | $\color{red}{1}$ | $\color{green}{C}$ | + | |each position in hexadecimal | $\color{red}{1}$ | $\color{green}{\rm C}$ | $\color{blue}{4}$ | |
- | The result is $\color{red}{1}\color{green}{C}\color{blue}{4}_{16}$ | + | The result is $\color{red}{1}\color{green}{\rm C}\color{blue}{4}_{16}$ |
</ | </ | ||
Zeile 216: | Zeile 216: | ||
^each position in decimal | ^each position in decimal | ||
- | |each position in hexadecimal | $\color{blue }{1}$ | $\color{green}{\rm E}$ | $\color{brown}{B}$ | + | |each position in hexadecimal | $\color{blue }{1}$ | $\color{green}{\rm E}$ | $\color{brown}{\rm B}$ | $\color{red |
- | The result is $0.\overline{ \color{blue }{1} \color{green}{E} \color{brown}{B} \color{red | + | The result is $\rm 0.\overline{ \color{blue }{1} \color{green}{E} \color{brown}{B} \color{red |
</ | </ | ||
Zeile 301: | Zeile 301: | ||
+672 \\ | +672 \\ | ||
\hline | \hline | ||
- | 1\overset{\color{red}{2}}{1}\overset{\color{red}{1}}{4}\overset{}{2} | + | 1\overset{\color{red}{2}}{2}\overset{\color{red}{1}}{4}\overset{}{2} |
\end{align*} | \end{align*} | ||
Zeile 387: | Zeile 387: | ||
\begin{align*} | \begin{align*} | ||
\begin{array}{lll} | \begin{array}{lll} | ||
- | { | + | {a) \\ |
- | a) \\ | + | \color{white} |
- | \color{white}{+}5_{16} \\ | + | |
- | +3_{16}\\ | + | |
\, | \, | ||
- | }&{ | + | }&{ b) \\ |
- | b) \\ | + | \color{white} |
- | \color{white}{+}7_{16} \\ | + | |
- | +3_{16}\\ | + | \, |
- | \, | + | }&{ c) \\ |
- | }&{ | + | \color{white} |
- | c) \\ | + | |
- | \color{white}{+}\, | + | \, |
- | +D_{16}\\ | + | }&{ d) \\ |
- | \, | + | \color{white} |
- | }&{ | + | |
- | d) \\ | + | |
- | \color{white}{+}E_{16} \\ | + | |
- | +A_{16}\\ | + | |
\; | \; | ||
} | } | ||
Zeile 412: | Zeile 408: | ||
a) This one is simple: looks like a decimal formula.. \\ | a) This one is simple: looks like a decimal formula.. \\ | ||
- | b) Here, the summands look like decimal numerals, but the result $7_{10} + 3_{10} = 10_{10}$ is still within the range of the base. The correct symbol would be $10_{10} = A_{16}$ \\ | + | b) Here, the summands look like decimal numerals, but the result $7_{10} + 3_{10} = 10_{10}$ is still within the range of the base. The correct symbol would be $10_{10} = \rm A_{16}$ \\ |
- | c) Now, the summands are a "bit more hexadecimally" | + | c) Now, the summands are a "bit more hexadecimally" |
- | d) Also for this calculation the described way is beneficial: $E_{16} + A_{16} = 14_{10} + 10_{10} = 24_{10}$. The result is larger than the base, and therefore the value has to be separated in more digits: $24_{10} = 16_{10} + 8_{10} = 10_{16} + 8_{16} = 18_{10}$ \\ | + | d) Also for this calculation the described way is beneficial: $\rm E_{16} + A_{16} = 14_{10} + 10_{10} = 24_{10}$. The result is larger than the base, and therefore the value has to be separated in more digits: $24_{10} = 16_{10} + 8_{10} = 10_{16} + 8_{16} = 18_{10}$ \\ |
For a hexadecimal value with more digits, the carry of the calculation before has to be added - otherwise, every step remains the same. | For a hexadecimal value with more digits, the carry of the calculation before has to be added - otherwise, every step remains the same. | ||
Zeile 426: | Zeile 422: | ||
\begin{align*} | \begin{align*} | ||
\begin{array}{lll} | \begin{array}{lll} | ||
- | { | + | { a) \\ |
- | a) \\ | + | \color{white} |
- | \color{white}{-}0_2 \\ | + | |
- | -0_2\\ | + | |
\, | \, | ||
- | }&{ | + | }&{ b) \\ |
- | b) \\ | + | \color{white} |
- | \color{white}{-}1_2 \\ | + | |
- | -1_2\\ | + | |
\, | \, | ||
- | }&{ | + | }&{ c) \\ |
- | c) \\ | + | \color{white} |
- | \color{white}{-}1_2 \\ | + | |
- | -0_2\\ | + | |
\, | \, | ||
- | }&{ | + | }&{ d) \\ |
- | d) \\ | + | \color{white} |
- | \color{white}{-}0_2 \\ | + | |
- | -1_2\\ | + | |
\; | \; | ||
} | } | ||
Zeile 452: | Zeile 444: | ||
The calculation for $d)$ shows the carry, which here has to borrow a bit from the next upper digit. This is similar to the calculation: | The calculation for $d)$ shows the carry, which here has to borrow a bit from the next upper digit. This is similar to the calculation: | ||
\begin{align*} | \begin{align*} | ||
- | \color{white}{-}42_{10} \\ | + | \color{white} |
- | -23_{10}\\ | + | - 23_{10}\\ |
- | \; | + | \; |
\end{align*} | \end{align*} | ||
Zeile 460: | Zeile 452: | ||
\begin{align*} | \begin{align*} | ||
- | \color{white}{-}\, | + | \color{white} |
- | -01\boldsymbol{1}1_2\\ | + | - |
\, | \, | ||
\end{align*} | \end{align*} | ||
Zeile 468: | Zeile 460: | ||
\begin{align*} | \begin{align*} | ||
- | \color{white}{-}\, | + | \color{white} |
- | -\boldsymbol{1}_2\\ | + | |
\overline{ \overset{\color{red}{1}} {\color{white}{0}} \overset{\color{red}{\boldsymbol{1}}} {\boldsymbol{1}}_2 } | \overline{ \overset{\color{red}{1}} {\color{white}{0}} \overset{\color{red}{\boldsymbol{1}}} {\boldsymbol{1}}_2 } | ||
\end{align*} | \end{align*} | ||
- | The calculation has to be executed as follows: $\boldsymbol{1}_2 - (\boldsymbol{1}_2 + \color{red}{\small{\boldsymbol{1}}} ) = {\boldsymbol{1}}_2 $. Additionally, | + | The calculation has to be executed as follows: $\boldsymbol{1}_2 - (\boldsymbol{1}_2 + \color{red}{\small{\boldsymbol{1}}} ) = {\boldsymbol{1}}_2 $. |
+ | Additionally, | ||
=== In Hexadecimal === | === In Hexadecimal === | ||
The calculation in hexadecimal is conceptually again the same. Some examples, which we will discuss below: | The calculation in hexadecimal is conceptually again the same. Some examples, which we will discuss below: | ||
- | |||
\begin{align*} | \begin{align*} | ||
+ | \rm | ||
\begin{array}{lll} | \begin{array}{lll} | ||
- | { | + | { a) \\ |
- | a) \\ | + | |
- | \color{white}{-}15_{16} \\ | + | |
- | -\color{white}{1}3_{16}\\ | + | |
\, | \, | ||
- | }&{ | + | }&{ b) \\ |
- | b) \\ | + | |
- | \color{white}{-}23_{16} \\ | + | |
- | -\color{white}{B}6_{16}\\ | + | \overline{\color{white}{-}\overset{\color{red}{1}}{1} |
- | \overline{\color{white}{-}\overset{\color{red}{1}}{1}D_{16}} | + | }&{ c) \\ |
- | }&{ | + | |
- | c) \\ | + | -1{\rm A}_{16}\\ |
- | \color{white}{-}3F_{16} \\ | + | |
- | -1A_{16}\\ | + | |
\color{white}{-}\overline{\color{white}{B}\overset{}{25_{16}}} | \color{white}{-}\overline{\color{white}{B}\overset{}{25_{16}}} | ||
- | }&{ | + | }&{ d) \\ |
- | d) \\ | + | |
- | \color{white}{+}\, | + | |
- | +1A_{16}\\ | + | \color{white}{+}\overline{\overset{\color{red}{1}}{1}\overset{}{{\rm B}_{16}}} |
- | \color{white}{+}\overline{\overset{\color{red}{1}}{1}\overset{}{B_{16}}} | + | |
} | } | ||
\end{array} | \end{array} | ||
Zeile 507: | Zeile 496: | ||
a) This one is (again) simple: looks (again) like a decimal formula.. \\ | a) This one is (again) simple: looks (again) like a decimal formula.. \\ | ||
- | b) Here, both hexadecimal numerals look like decimal numerals, but the result $3_{10} - 6_{10} = 7_{10} + C$ lead to an underflow, where we have to take a carry of $C=-10_{10}$ for a decimal calculation. In hexadecimal, | + | b) Here, both hexadecimal numerals look like decimal numerals, but the result $3_{10} - 6_{10} = 7_{10} + C$ lead to an underflow, where we have to take a carry of $C=-10_{10}$ for a decimal calculation. In hexadecimal, |
- | c) For this formula the idea from b) helps, too: for each digit-by-digit subtraction, | + | c) For this formula the idea from b) helps, too: for each digit-by-digit subtraction, |
- | d) We can do the same thing here, for $8_{16}-A_{16}$: | + | d) We can do the same thing here, for $8_{16}-A_{16}$: |
<WRAP column 100%> <panel type=" | <WRAP column 100%> <panel type=" | ||
Zeile 560: | Zeile 549: | ||
* [[https:// | * [[https:// | ||
+ | * The [[https:// | ||
* A short video on the " | * A short video on the " | ||
Zeile 591: | Zeile 581: | ||
Tip: Convert nibble by nibble to binary. | Tip: Convert nibble by nibble to binary. | ||
- | - $4321H$ | + | - $\rm 4321H$ |
- | - $0xCAFE$ | + | - $\rm 0xCAFE$ |
- | - $ \$ $$4be79 $ | + | - $ \$ $$\rm 4be79 $ |
- | - $ \$ $$398B4C $ | + | - $ \$ $$\rm 398B4C $ |
- | - $0x3a4f.4ecd $ | + | - $\rm 0x3a4f.4ecd $ |
- | - $\$1.3DAF $ | + | - $\$\rm 1.3DAF $ |
</ | </ | ||
Zeile 605: | Zeile 595: | ||
Tip: Use the numerals from Exercise 2.3.1. | Tip: Use the numerals from Exercise 2.3.1. | ||
- | - $0b10110110$ | + | - $\rm 0b10110110$ |
- $\%10100101$ | - $\%10100101$ | ||
- | - $1111\, 0111\, 0001\, 0011B$ | + | - $\rm 1111\, 0111\, 0001\, 0011B$ |
- | - $0110111.0101b$ | + | - $\rm 0110111.0101b$ |
- | - $0.10101b$ | + | - $\rm 0.10101b$ |
- | - $0.1001\, 1001\, ... b$ | + | - $\rm 0.1001\, 1001\, ... b$ |
</ | </ | ||
Zeile 633: | Zeile 623: | ||
Execute the following operations manually with the given dual numerals. \\ | Execute the following operations manually with the given dual numerals. \\ | ||
- | - $01110111B + 11010101B$ | + | - $\rm 01110111B + 11010101B$ |
- | - $01011001B + 10011111B$ | + | - $\rm 01011001B + 10011111B$ |
- | - $01100111B - 01001100B$ | + | - $\rm 01100111B - 01001100B$ |
- | - $10101110B - 10000111B$ | + | - $\rm 10101110B - 10000111B$ |
- | - $0011.111B - 0011.100B$ | + | - $\rm 0011.111B - 0011.100B$ |
- | - $001111.011B + 1.010011B$ | + | - $\rm 001111.011B + 1.010011B$ |
- | - $01101.100B - 01000.111B$ | + | - $\rm 01101.100B - 01000.111B$ |
- | - $100101.11B - 110001.10B$ | + | - $\rm 100101.11B - 110001.10B$ |
</ | </ | ||
Zeile 648: | Zeile 638: | ||
Execute the following operations manually with the given dual numerals. \\ | Execute the following operations manually with the given dual numerals. \\ | ||
- | - $1011B \cdot 0101B$ | + | - $\rm 1011B \cdot 0101B$ |
- | - $01100101B \cdot 110B$ | + | - $\rm 01100101B \cdot 110B$ |
- | - $10101111B : 101B$ | + | - $\rm 10101111B : 101B$ |
- | - $11110000B : 1000B$ | + | - $\rm 11110000B : 1000B$ |
</ | </ | ||
Zeile 658: | Zeile 648: | ||
Execute the following operations manually with the given dual numerals. \\ | Execute the following operations manually with the given dual numerals. \\ | ||
- | - $1334H + 07ABH$ | + | - $\rm |
- | - $0DC43H - 0BD19H$ | + | - $\rm 0DC43H - 0BD19H$ |
- | - $1F23H + 90E8H$ | + | - $\rm |
- | - $98C5H - 84CAH$ | + | - $\rm |
- | - $234AH + 7EE6H$ | + | - $\rm |
- | - $0F10CH - 0ED43H$ | + | - $\rm 0F10CH - 0ED43H$ |
</ | </ | ||
Zeile 674: | Zeile 664: | ||
</ | </ | ||
- | <panel type=" | + | <panel type=" |
- | In the simulation in <imgref pic70> the one's complement of a 4bit value is shown. \\ | + | In the simulation in <imgref pic70> the two's complement of a 4bit value is shown. \\ |
- | On initialization the value is the following: | + | On initialization, the value is the following: |
- | * The value for $A$ is $1010_2 = 10_{10}$. The decimal value '' | + | * The value for variable |
- | * The value for $B$ is $1110_2 = 14_{10}$. The decimal value '' | + | * The value for variable |
- | * The addition $A+B$ leads to $S = 1000_2 = 8_{10}$. The decimal value '' | + | * The addition $A+B$ leads to $S = 1000_2 = 8_{10}$. The decimal value '' |
- | * There is another value in the second display from the right. This is called $B'$ and it is equal to $0010_2 = 2_{10}$. | + | * There is another value in the second display from the right. This is called $B'$, and it is equal to $0010_2 = 2_{10}$. |
< | < | ||
- | < | + | < |
- | {{url> | + | {{url> |
</ | </ | ||
- Why is '' | - Why is '' | ||
- Try to analyze how '' | - Try to analyze how '' | ||
- | - Have a look at the wiki page of the {{wp>Ones' complement}} to understand how negative numbers are represented in a microcontroller. | + | - Have a look at the wiki page of the {{wp>Two's complement}} to understand how negative numbers are represented in a microcontroller. |
- Imagine that you have to rescue data from an old storage device. The interesting bits are given by the boxed area in <imgref picex01> | - Imagine that you have to rescue data from an old storage device. The interesting bits are given by the boxed area in <imgref picex01> | ||
- What are these values in an unsigned integer? | - What are these values in an unsigned integer? | ||
- | - What are these values in signed integers based on the ones' complement? | + | - What are these values in signed integers based on the Two's complement? |