Beide Seiten der vorigen Revision
Vorhergehende Überarbeitung
Nächste Überarbeitung
|
Vorhergehende Überarbeitung
|
introduction_to_digital_systems:number_systems [2023/11/15 08:49] mexleadmin [2.2 basic arithmetic operations in binary and hexadecimal] |
introduction_to_digital_systems:number_systems [2023/11/16 01:09] mexleadmin |
</WRAP></WRAP></panel> | </WRAP></WRAP></panel> |
| |
<panel type="info" title="Exercise 2.3.9. One's Complement"> <WRAP group><WRAP column 2%>{{fa>pencil?32}}</WRAP><WRAP column 92%> | <panel type="info" title="Exercise 2.3.9. Two's Complement"> <WRAP group><WRAP column 2%>{{fa>pencil?32}}</WRAP><WRAP column 92%> |
| |
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 ''10'' is also shown in the first display from the left in the circuit. | * The value for variable $A$ is $1010_2 = 10_{10}$. The decimal value ''10'' is also shown in the first display from the left in the circuit. |
* The value for $B$ is $1110_2 = 14_{10}$. The decimal value ''14'' is also shown in the second display from the left in the circuit. | * The value for variable $B$ is $1110_2 = 14_{10}$. The decimal value ''14'' is also shown in the second display from the left in the circuit. |
* The addition $A+B$ leads to $S = 1000_2 = 8_{10}$. The decimal value ''10'' is also shown in the rightmost display in the circuit. | * The addition $A+B$ leads to $S = 1000_2 = 8_{10}$. The decimal value ''10'' is also shown on the rightmost display in the circuit. |
* 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}$. |
| |
<WRAP><well> | <WRAP><well> |
<imgcaption pic70|One's Complement></imgcaption> \\ | <imgcaption pic70|Two's Complement></imgcaption> \\ |
{{url>https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgzCAMB0l3BOJyWoSALNATAVmwIyQAc28kAbNgOzrbEi6OSMCmAtAQQFBnUjswYCiAI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DDB9F96ww+4cabDGF3rU9V0BMcl3XN8MYlYdszRCly149x5NY6KGVUwTaX0gzJLMxu1xnpM0xvkeB6SXTHZ8yVRPZezTKTDWdJCQqc3voK7iS5k4qcAWlzSnDKhCUJytBNDQo2C6mQKTLbKKAAhCAACSAB2ABurAAE4AC4O-0AAaYAADSu9gXsEF7LAAPTux7Qc+0HftByw1t207LvkOUACOXBcOUVvwAQifJ5AqdwEQmdEBnaeQCnSdENnadl5nxeF8XxdV3nFd50nuc58nVdwKnZfZwn1eF2XGc91w5cF93td99Xie18Plc9xPVtDwPufT036ed23s8d1bSi8lLjh9HV0cO879tEv0ihdI46YeuwX1PhA7Us9OguoeM-MNsT3DmwACiCACuYKFBYMHb2vt-YgBCJ7EIPsQh+xCCwH+-9AHwEni3IuddZ4NyXiglORcS5T1bh3QedcK7oOruXMhk826NwHl3TuyDm7EP7vXYetd67jxLkPaehCF5r3QVnNeTdk593XvHLex5zytXYC9OqCCAGn2NOECgQxqyFH4AkNoCdFGFFUCo8M2QGCJxSBgSM2iwAqA0BIKMAgUhgEgiBHovIaD6NyF4RoGQDYRHiKIJIABycIT4ZxKk8c4sIaNmqBMeizVs0EDr0RbP2UwO1AllmrDTQJWtoL+WgrmGJBYwx8xyaYXqnAuruniYWY0Q5UmFj5iyTMU07ilNELiJErwliVP6C8U4SwImRjqK07pLomklM9CcHYrjcCuBUBgZoUorHsBSLQTATIKD3zUd4kAAAKQxXhsC4lMGAIYTB1EAEpwIfi0kEJ8YYGwegbEZJY9yJANhemM7gQA noborder}} | {{url>https://www.falstad.com/circuit/circuitjs.html?ctz=CQAgzCAMB0l3BOJyWoSALNATAVmwIyQAc28kAbNgOzrbEi6OSMCmAtAQQFBnUjswYCiAIYMAsPlHSJAQUi9I-QcNH1J0gmUwg5PPpLVdsm09pbzsSlUJEIRgrZAnyw3AB4gEppkQkMEgQMAJqeAtgYDI7YauhBDABC4YIYLLYaRLrBeik05gQRuH6u4CwAOgAOedSmGOjseEyyZSBV3BgE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AhCAACSAB2ABurAAE4AC4O-0AAaYAADSu9gXsEF7LAAPTux7Qc+0HftByw1t207LvkOUACOXBcOUVvwAQifJ5AqdwEQmdEBnaeQCnSdENnadl5nxeF8XxdV3nFd50nuc58nVdwKnZfZwn1eF2XGc91w5cF93td99Xie18Plc9xPVtDwPufT036ed23s8d1bSi8lLjh9HV0cO879tEv0ihdI46YeuwX1PhA7Us9OguoeM-MNsT3DmwACiCACuYKFBYMHb2vt-YgBCJ7EIPsQh+xCCwH+-9AHwEni3IuddZ4NyXiglORcS5T1bh3QedcK7oOruXMhk826NwHl3TuyDm7EP7vXYetd67jxLkPaehCF5r3QVnNeTdk593XvHLex5zytXYC9OqCCAGn2NOECgQxqyFH4AkNoCdFGFFUCo8M2QGCJxSBgSM2iwAqA0BIKMAgUhgEgiBHovIaD6NyF4RoGQDYRHiKIJIABycIT4ZxKk8c4sIaNmqBMeizVs0EDr0RbP2UwO1AllmrDTQJWtoL+WgrmGJBYwx8xyaYXqnAuruniYWY0Q5UmFj5iyTMU07ilNELiJErwliVP6C8U4SwImRjqK07pLomklM9CcHYrjcCuBUBgZoUorHsBSLQTATIKD3zUd4kAAAKQxXhsC4lMGAIYTB1EAEpwIfi0kEJ8YYGwegbEZJY9yJANhemM7gQA noborder}} |
</well></WRAP> | </well></WRAP> |
- Why is ''10'' + ''14'' = ''8''? What happens to other values? \\ The input values ''A'' and ''B'' can be changed by clicking on the bit values. | - Why is ''10'' + ''14'' = ''8''? What happens to other values? \\ The input values ''A'' and ''B'' can be changed by clicking on the bit values. |
- Try to analyze how ''B''' (shown in the brackets) is derived from ''B''. | - Try to analyze how ''B''' (shown in the brackets) is derived from ''B''. |
- 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. \\ What does the following representation show? \\ {{drawio>introduction_to_digital_systems:SignedIntCircle.svg}} |
- Imagine that you have to rescue data from an old storage device. The interesting bits are given by the boxed area in <imgref picex01>. The bytes are LSB 0 oriented. | - Imagine that you have to rescue data from an old storage device. The interesting bits are given by the boxed area in <imgref picex01>. The bytes are LSB 0 oriented. |
- 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? |
| |
| |