User Tools

Site Tools


Sidebar

projects

wcp1 (due 20230125)
ntr0 (due 20230126)
pct0 (bonus; due 20230129)
pct1 (bonus; due 20230129)
dap0 (due 20230201)
wcp2 (due 20230201)
pct2 (due 20230202)
ngf0 (due 20230208)
pct3 (bonus; due 20230208)
wcp3 (due 20230208)
wcp4 (due 20230215)
dtr0 (due 20230216)
pct4 (due 20230216)
bwp1 (bonus; due 20230301)
ngf1 (due 20230301)
pct5 (bonus; due 20230301)
wcp5 (due 20230301)
dow0 (due 20230308)
gfo0 (due 20230308)
wcp6 (due 20230308)
pct6 (due 20230309)
ngf2 (due 20230315)
pct7 (bonus; due 20230315)
wcp7 (due 20230315)
pct8 (due 20230322)
wcp8 (due 20230322)
cnv0 (due 20230323)
ngf3 (due 20230329)
pct9 (bonus; due 20230329)
wcp9 (due 20230329)
bwp2 (bonus; due 20230412)
gfo1 (due 20230412)
ngf4 (due 20230412)
pctA (due 20230412)
wcpA (due 20230412)
oop0 (due 20230419)
pctB (bonus; due 20230419)
wcpB (due 20230419)
oop1 (due 20230426)
pctC (due 20230426)
wcpC (due 20230426)
oop2 (due 20230503)
pctD (bonus; due 20230503)
wcpD (bonus; due 20230503)
gfo2 (due 20230510)
pctE (bonus; due 20230510)
wcpE (bonus; due 20230510)
EoCE (due 20230518)
haas:spring2023:cprog:signedvalues

Signed vs. Unsigned Values

Binary (Base 2) Signed Decimal (Base 10) Unsigned Decimal (Base 10) Hexadecimal (Base 16)
0 0 0 0 0 0 0x0
0 0 0 1 1 1 0x1
0 0 1 0 2 2 0x2
0 0 1 1 3 3 0x3
0 1 0 0 4 4 0x4
0 1 0 1 5 5 0x5
0 1 1 0 6 6 0x6
0 1 1 1 7 7 0x7
1 0 0 0 -8 8 0x8
1 0 0 1 -7 9 0x9
1 0 1 0 -6 10 0xA
1 0 1 1 -5 11 0xB
1 1 0 0 -4 12 0xC
1 1 0 1 -3 13 0xD
1 1 1 0 -2 14 0xE
1 1 1 1 -1 15 0xF

A signed value is when we take a bit (usually the most significant bit) and reserve it for the sign. This shifts the representable range of values, straddling 0. We still have the same quantity of values as in the unsigned range, we just represent them differently.

We use a technique called two's complement to represent signed values (the negative values, specifically).

In this case, a leading 0 indicates a positive value, and a leading 1 indicates a negative value.

For example- 1000, leading one, so negative. Negative what?

Step one- invert: 1000 becomes 0111.

Step two- add one: 0111+1 = 1000. This is a -8.

Another example: 1101.

Invert: 0010

Add one: 0010+1 = 0011 (this is a 3, and we know we started with a leading 1, so 1101 is -3).

haas/spring2023/cprog/signedvalues.txt · Last modified: 2012/09/15 15:06 by 127.0.0.1