# Two's Complement and Group Theory

DevFeed: [Two's Complement and Group Theory](<https://devfeed.tech/articles/two-s-complement-and-group-theory-40465.md>)

Original publisher: [Read original article](<https://www.jeremykun.com/2023/07/10/twos-complement-and-group-theory/>)

Published: 2023-07-10T07:00:00Z

Content type: article

Language: en

Sources: [Jeremy Kun](<https://devfeed.tech/sources/jeremy-kun.md>)

Topics: [math](<https://devfeed.tech/topics/math.md>), [Mathematics](<https://devfeed.tech/topics/mathematics.md>), [Computer science](<https://devfeed.tech/topics/computer-science.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [abelian-groups](<https://devfeed.tech/tags/abelian-groups.md>), [arithmetic](<https://devfeed.tech/tags/arithmetic.md>), [bits](<https://devfeed.tech/tags/bits.md>), [boolean](<https://devfeed.tech/tags/boolean.md>), [circuits](<https://devfeed.tech/tags/circuits.md>), [computer-science](<https://devfeed.tech/tags/computer-science.md>), [group-actions](<https://devfeed.tech/tags/group-actions.md>), [groups](<https://devfeed.tech/tags/groups.md>), [math](<https://devfeed.tech/tags/math.md>), [mathematics](<https://devfeed.tech/tags/mathematics.md>), [programming](<https://devfeed.tech/tags/programming.md>), [quotients](<https://devfeed.tech/tags/quotients.md>), [symmetry](<https://devfeed.tech/tags/symmetry.md>), [twos-complement](<https://devfeed.tech/tags/twos-complement.md>)

## AI overview

The article explains two's-complement signed integer arithmetic using group theory. It presents signed and unsigned n-bit integers as representations of the quotient group of integers modulo 2^n, clarifying why the same arithmetic circuits can operate on both.

## Source excerpt

Before I discovered math, I was a first year undergrad computer science student taking Electrical Engineering 101. The first topic I learned was what bits and boolean gates are, and the second was the two's complement representation of a negative n-bit integer. At the time two's complement seemed to me like a bizarre quirk of computer programming, with minutiae you just had to memorize. If the leading bit is 1, it's negative, and otherwise it's positive.