Two's complement: Difference between revisions - Wikipedia
Article Images
Content deleted Content added
Mazewaxie 113,286 edits m |
Tags: Reverted Mobile edit Mobile app edit iOS app edit |
||
Line 305: ==Why it works== Given a set of all possible {{mvar|N}}-bit values, we can assign the lower (by the binary value) half to be the integers from 0 to {{math|(2<sup>''N'' − 1</sup> − 1)}} inclusive and the upper half to be {{math|−2<sup>''N'' − 1</sup>}} to −1 inclusive. The upper half (again, by the binary value) can be used to represent negative integers from {{math|−2<sup>''N'' − 1</sup>}} to −1 because, under addition modulo {{math|2<sup>''N''</sup>}} they behave the same way as those negative integers. That is to say that because {{math|1= ''i'' + ''j'' mod 2<sup>''N''</sup> = ''i'' + (''j'' + ''k'' 2<sup>''N''</sup>) mod 2<sup>''N''</sup>}} any value in the set {{math|1= { ''j'' + ''k'' 2<sup>''N''</sup> {{!}} ''k'' is an integer } }} can be used in place of {{mvar|j}}.<ref>{{cite web | url = http://www.cs.uwm.edu/~cs151/Bacon/Lecture/HTML/ch03s09.html | title = 3.9. Two's Complement | work = Chapter 3. Data Representation |