Intro

An 8-bit integer uses 8 binary digits (bits) to store numbers, allowing for 2⁸ (256) unique values.

  • unsigned range: 0 to 255
  • signed range: -128 to 127

Applications:

  • Pixel intensity in images (0–255)
  • RGB color channels in digital graphics
  • Representing characters (ASCII)
  • Small integers in embedded systems

Byte vs 8-Bit Integer

A byte is the basic unit of digital storage, historically 8 bits today.
An 8-bit integer is a numeric value that fits in one byte.

Worked Example: Hex ↔ Binary ↔ Decimal

Binary → Decimal ( 11111111)

1   1   1   1   1   1   1   1
2⁷  2⁶  2⁵  2⁴  2³  2²  2¹  2⁰

Calculation:

11111111₂ = 1×2⁷ + 1×2⁶ + 1×2⁵ + 1×2⁴ + 1×2³ + 1×2² + 1×2¹ + 1×2⁰
          = 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
          = 255

Binary → Hex ( 11111111)

To convert binary → hex, you must group bits into nibbles (sets of 4) starting from the right:

1111 1111

Convert each group:

1111₂ = 1×2³ + 1×2² + 1×2¹ + 1×2⁰
      = 8 + 4 + 2 + 1
      = 15₁₀ -> F₁₆

Result:

11111111₂ = FF₁₆

Verification: Hex → Decimal ( FF)

F      F
16¹    16⁰

Each F = 15

Calculation:

FF₁₆ = 15×16¹ + 15×16⁰
     = 15×16  + 15×1
     = 240 + 15
     = 255

Conclusion:

FF₁₆ = 11111111₂ = 255₁₀