Course list: http://www.c-jump.com/bcc/

Bits, Bytes, Hexadecimals, and ASCII


  1. Bit
  2. Byte
  3. Byte, example
  4. Nibble
  5. Hexadecimal Notation
  6. 2's complement integers
  7. Computing 2's complement example
  8. ASCII characters

1. Bit


2. Byte


3. Byte, example


4. Nibble


5. Hexadecimal Notation


  • Simplifies notation of bit patterns.

  • Much better alternative, compared to binary number notation.

  • Simplifies notation of long binary strings, such as entire blocks of computer memory.

  • Hexadecimal notation is used mainly for human convinience.

  • Hexadecimal notation represents numbers
    of base 16, calculated as

    • h3*163 + h2*162 + h1*161 + h0*160

    where h3, h2, h1, and h0 are values from the Hexadecimal column of the table.

  •  

    Decimal Hexadecimal Octal Binary
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    A
    B
    C
    D
    E
    F
    000
    001
    002
    003
    004
    005
    006
    007
    010
    011
    012
    013
    014
    015
    016
    017
    0000
    0001
    0010
    0011
    0100
    0101
    0110
    0111
    1000
    1001
    1010
    1011
    1100
    1101
    1110
    1111

6. 2's complement integers


  • Positive integers are represented in a straightfoward positional scheme.

  • Corresponding negative integer binary representations are calculated by the following steps:

    1. Invert each bit of the positive number.

    2. Add 1.

    3. If there is a carry over from the highest bit, ignore it.

  • The same steps are used to go from negative back to positive number.

  • 8 bit two's complement:

    Binary value Two's complement interpretation Unsigned interpretation
    00000000 0 0
    00000001 1 1
    ... ... ...
    01111110 126 126
    01111111 127 127
    10000000 -128 128
    10000001 -127 129
    10000010 -126 130
    ... ... ...
    11111110 -2 254
    11111111 -1 255

7. Computing 2's complement example

  • To obtain 2's complement representation of decimal -13 (negative thirteen)

    1. Take representation of positive 13:

      • 01101

    2. Compute complement by flipping each bit:

      • 10010

    3. Add 1:

      • 10011 (decimal -13)

  • To go back from -13 to positive 13, execute the same exact steps:

    1. Take representation of negative 13:

      • 10011

    2. Invert each bit:

      • 01100

    3. Add 1:

      • 01101 (decimal 13)

8. ASCII characters