Skip to main content

Timeline for answer to What is “two's complement”? by lavinio

Current License: CC BY-SA 4.0

Post Revisions

34 events
when toggle format what by license comment
Oct 7, 2025 at 0:37 comment added Siamak Worth mentioning with this method moving data around (ex 4bits > 16bits) is super easy, just need to fill the new bits with the left most bit, and the value is intact. Same for the opposite, just cut the binary number from the left and as long as the new system can hanlde your number, it remains intact. Meaning, no computation for data transfer. It's just brilliant! Also, negative numbers are representation of [biggest decimal] - [number] = [negative number representation] in 4bits: 8-3 = 5(101) -3=1 101
Aug 5, 2021 at 13:42 history edited Chris Akridge CC BY-SA 4.0
Clarify the direction of negative numbers
Jun 12, 2021 at 2:36 comment added paxdiablo It should also be pointed out that both C cand C++ standards committees are currently in the process of adopting two's complement as the "one true ring", ditching sign/magnitude and ones' complement as "blessed" alternatives.
Jun 12, 2021 at 2:34 comment added paxdiablo I'm going to upvote this based solely on the fact it got the apostrophes in the right place regarding ones' complement and two's complement :-) As Knuth himself points out, the former is complementing based on a series of ones, the latter complementing based on a single power of two. Twos' complement exists but I think that's for base-3 (or 4?) numbers, not binary.
Mar 29, 2021 at 13:15 history edited Ardent Coder CC BY-SA 4.0
active reading
Sep 15, 2020 at 19:49 comment added Charlie Parker I think this is a better explanation of what complements means: I think a comment that was helpful to me is that complement is similar to inverse but instead of giving 0 it gives 2^N (by definition) e.g. with 3 bits for the number A we want A+~A=2^N so 010 + 110 = 1000 = 8 which is 2^3. At least that clarifies what the word "complement" is suppose to mean here as it't not just the inverting of the meaning of 0 and 1.
Sep 15, 2020 at 19:41 comment added Charlie Parker I think a useful comment on the answer would be why complement does not mean inverse. Also, starting counting at 1111 and that being -1 but then start counting on 0000 and that not being 1 is strange. Why not start counting at 1111 and let that be zero? Since the most natural "complementing" of digit meaning would have meant that 1110 is -1 but that is not the case and is really confusing.
Aug 23, 2020 at 3:11 history edited pizzapants184 CC BY-SA 4.0
Correct "one's complement" to "sign-magnitude" and add additional description of "one's complement"
Mar 6, 2020 at 7:27 history edited L. F. CC BY-SA 4.0
deleted 2 characters in body
Jul 29, 2019 at 10:04 history edited Michael Baker CC BY-SA 4.0
added 2 characters in body
May 11, 2019 at 13:36 comment added Amin Soheyli Note that, 2's complement does not use for floating points numbers. A simple representation of floating points is IEEE 754.
S Nov 14, 2018 at 19:43 history suggested StevePoling CC BY-SA 4.0
Added a mention of one's compliment arithmetic to provide context.
Nov 14, 2018 at 15:12 review Suggested edits
S Nov 14, 2018 at 19:43
Apr 13, 2018 at 18:29 comment added mgagnon @FatalError It depends on how many bits the number is represented. 1101 = -3 (4 bits) , but 00001101 = 13 (8 bits).
Feb 18, 2018 at 3:36 comment added Rain But how does the computer for example know if 1101 is negative three and not 13?
Dec 11, 2017 at 20:56 comment added mckenzm To me, these look like binary values. Two's complement generally involves bitwise inversion and an addition. So not really explanatory other than explaining binary ? For a 32 bit 'fullword' 8000 up is -ve, sure. But what is the purpose from an ALU POV ?
Jul 12, 2017 at 19:48 comment added NH. The sign bit is still valid (except perhaps for the case of 0, which isn't positive or negative), but you don't simply change the sign bit to negate a number (see below for negation).
Mar 30, 2017 at 0:40 comment added MarcusJ So, does 2's complement simply not use a sign bit at all?
Feb 26, 2017 at 2:49 history edited Milind Deore CC BY-SA 3.0
added 95 characters in body
Aug 30, 2016 at 12:52 comment added Xunie I think the integer overflow concept might be better explained if for the negatives we start counting at the lowest number. (That is: negative eight and count up again). This way the student might see why an integer overflow results in such arbitrary numbers.
Aug 22, 2016 at 22:35 comment added Suraj Jain Awesome .Added extra parts of converting bits to negative integer.
Aug 22, 2016 at 22:27 review Suggested edits
Aug 23, 2016 at 1:04
Feb 29, 2016 at 10:30 history edited jbutler483 CC BY-SA 3.0
added 238 characters in body
Jan 17, 2016 at 14:49 history edited ROMANIA_engineer CC BY-SA 3.0
deleted 19 characters in body
Nov 29, 2015 at 19:22 review Suggested edits
Nov 29, 2015 at 20:23
Jan 27, 2015 at 11:41 comment added Koray Tugay Shouldn't you say "for negative integers, do exactly the same thing but count down and switch the role of 0's and 1's"
Dec 26, 2014 at 5:22 comment added Ashwin Upvote for it being to the point and also for explaining why the negative values have a larger range the positive ones. I came looking for the reason for the range difference.
Nov 19, 2014 at 18:50 review Suggested edits
Nov 19, 2014 at 19:26
Dec 8, 2012 at 1:27 history edited Mathew Kurian CC BY-SA 3.0
edited body
Aug 13, 2012 at 9:37 review Suggested edits
Aug 13, 2012 at 9:39
Jul 1, 2009 at 16:01 vote accept Frank V
Jun 26, 2009 at 16:52 comment added Jörg W Mittag Another advantage besides easy addition and subtraction is that 2s complement only has one zero. If you were using a simple sign bit, say using 0001 to represent +1 and 1001 to represent -1, you would have two zeros: 0000 ("+0") and 1000 ("-0"). That's a real pain in the behind.
Jun 26, 2009 at 15:52 comment added Naaff Probably the best part of two's complement is how it simplifies math. Try adding 2 (0010) and -2 (1110) together and you get 10000. The most significant bit is overflow, so the result is actually 0000. Almost like magic, 2 + -2 = 0.
Jun 26, 2009 at 15:29 history answered lavinio CC BY-SA 2.5