When we understand $\mathbb{Z}_{4}$ as $\{-2, -1, 0, 1\}$ rather than $\{0, 1, 2 ,3\}$, is it same as 2's complement?

67 Views Asked by At

Suppose we have an integer ring $\mathbb{Z}_4$. When we understand $\mathbb{Z}_{4}$ as $\{-2, -1, 0, 1\}$ rather than $\{0, 1, 2 ,3\}$, is it same as 2's complement using 2 bit?

2

There are 2 best solutions below

0
On

By definition, the group $\mathbb Z_4$ is the group $\mathbb Z/4\mathbb Z$ and has $4$ elements. The elements are sets, actually subsets of $\mathbb Z$. By definition, these sets are equivalence classes under the relation $x\sim y\iff x-y\in 4\mathbb Z$.

The zero element of $\mathbb Z_4$ is actuall the subgroup $4\mathbb Z$ itself, while the other four elements are $1+4\mathbb Z$, $2+4\mathbb Z$ and $3+4\mathbb Z$.

Usually, we write $\mathbb Z_4$ simply as $\{0,1,2,3\}$, but in fact, what we mean is $$\{0+4\mathbb Z, 1+4\mathbb Z, 2+4\mathbb Z, 3+4\mathbb Z\}$$

and, since $-2\sim2$, we know that $-2+4\mathbb Z = 2 + \mathbb Z$, so the set above is the same set as

$$\{0+4\mathbb Z, 1+4\mathbb Z, -2+4\mathbb Z, 3+4\mathbb Z\}$$

whic we would write, in short, as $\{0,1,-2,3\}$. You can similarly replace $3$ with $-1$ (because $3\sim -1$) and see that

$$\{0+4\mathbb Z, 1+4\mathbb Z, 2+4\mathbb Z, 3+4\mathbb Z\} = \{0+4\mathbb Z, 1+4\mathbb Z, -2+4\mathbb Z, -1+4\mathbb Z\}$$

or, in short,

$$\{0,1,2,3\} = \{0,1,-2,-1\}$$

where we must realize that this last equality only holds when looking at equivalence classes.

0
On

5xum has given a good explanation of $\mathbb{Z}_4$ but did not mention 2's complement.

Indeed, if you had a rather unusual 2 bit word in your computer and you stored integers in it using 2's complement then the possible values would be $\{-2, -1, 0, 1\}$ but that is about as much as I can see that they have in common.

The arithmetic of your unusual 2 bit word would be isomorphic to $\mathbb{Z}_4$ but that would also be true if you used unsigned integers. Similarly, the more common 8 bit bytes have arithmetic isomorphic to $\mathbb{Z}_{256}$ whether you regard them as signed or unsigned.

2's complement is a sometimes convenient storage technique in computers but not of great interest in mathematics.