Basic Computer Architecture

How does that thing works

On or Off

Two states that rule everything

0

1

42

Use our states for something bigger

0 0 1 0 1 0 1 0 42
27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
0 0 32 0 8 0 2 0 42
  • Binary system
  • One memory position = 1 Bit
  • Typically aligned to 8 Bits
  • Everything expressed that way, even fractions, characters, and much more
  • Left example can be 0 to 255
  • 00000000 = 0, 11111111 = 255

-42

What about the leading sign?

  • How to express negative values?
  • +/- are two states...
  • ...perfect for a bit
  • Use first bit as leading sign
  • -127 to +127
  • We lose a "unit" of capacity... but why?
  • We have -0 and +0... darn.
  • ...and it is hard to implement in hardware.
1 0 1 0 1 0 1 0 -42
+/- 26 25 24 23 22 21 20
+/- 64 32 16 8 4 2 1
- 0 32 0 8 0 2 0 -42

Two's Complement

Fixing the double zero problem and simplifying calculation

  • Don't reserve a place for the sign
  • The negative value is all bits inverted plus 1.
  • 00000000 = 0, 01111111 = 127
  • 11111111 = -128, 10000000 = -1
128 64 32 16 8 4 2 1
0 0 1 0 1 0 1 0 42
1 1 0 1 0 1 0 1 inverted
0 0 0 0 0 0 0 1 +1
1 1 0 1 0 1 1 0 -42