Data Representation

Binary

Data is processed using logic gates and stored in registers. Any form of data needs to be converted to binary (0 or 1) to be processed by a computer.

Number Systems

Topic Description
Binary2
Denary10
Hexadecimal16

Hexadecimal

Hexadecimal is used in areas like:

  • MAC adresses
  • IPv6 address
  • error codes
  • HTML colour codes

Hexadecimal is easier for humans to understand than binary, as it is a shorter representation of binary

Binary Addition

While adding 2 positive binary integers, there are some rules to follow. They are:

  • 0 + 0 = 0
  • 0 + 1 = 1
  • 1 + 1 = 10
  • 1 + 1 + 1 = 11

For example, 10010100 + 00011110 = 10110010.

1
1
0
0
1
0
1
0
0
1
0
1
1
1
1
0
0
0
+

0
1
0
0
1
1
0
1

Overflow Error

An overflow error will occur if the value is greater than 255 in an 8-bit register. A computer or a device has a predefined limit that it can represent or store, for example 16-bit. An overflow error occurs when a value outside this limit should be returned

Logical Shifts

When a logical left shift is done on an 8-bit binary integer the denary value of tdat is multiplied by 2 each time.

When a logical right shift is done on an 8-bit binary integer the denary value of tdat is divided by 2 each time.

  • Bits shifted from the end of the register are lost and zeros are shifted in at the opposite end of the register.
  • The most significant bit(s) or least significant bit(s) are lost

Two's Complement

-35

  1. Convert to binary
  2. 0
    0
    1
    0
    0
    0
    1
    1
  3. Flip all the bits
  4. 1
    1
    0
    1
    1
    1
    0
    0
  5. Add 1 at the last
  6. 1
    1
    0
    1
    1
    1
    0
    1

Character Sets

A character set contains symbols that are each assigned a unique binary value.

Character sets help convert text into binary for computers to process.

There are 2 types of character sets:

  • ASCII: it represents characters using 8-bit binary numbers (256 max)
  • Unicode: represents characaters using 16-bit binary numbers

Sound

A sound wave is sampled for sound to be converted to binary, which is processed by a computer.

  • Sample rate is the number of samples taken in a second
  • Sample resolution is the number of bits per sample
  • Accuracy of the recording and the file size increases as the sample rate and resolution increase

Images

An image is series of pixels that are converted to binary, which is processed by a computer.

  • The resolution is the number of pixels in the image.
  • The colour depth is the number of bits used to represent each colour.
  • The file size and quality of the image increases as the resolution and colour depth increase.

Measurement of Data Storage

Bits are the smallest unit of data. Bytes are commonly used to measure the size of data. Unlike denary units (kilobyte) which are multiplied by 1000, binary units (kibibyte) are multiplied by 1024.

  • Bits: the smallest unit
  • Nibble: 4 bits
  • Byte: 8 bits
  • Kibibyte (KiB): 1024 bytes
  • Mebibyte (MiB): 1024 KiB
  • Gibibyte (GiB): 1024 MiB
  • Tebibyte (TiB): 1024 GiB
  • Pebibyte (PiB): 1024 TiB
  • Exbibyte (EiB): 1024 PiB

Calculating File Size

The dimensions of images are measured in pixels.

  • Images: width × height × colour depth
  • Audio: sample rate × length × sample resolution

Data compression

It exists to reduce the the size of the file.

The impact of this is, eg:

  • less bandwith required
  • less storage required
  • shorter transimission time

Lossless compression reduces the file size without permanent loss of data, eg. run length encoding (RLE). It uses a compression algorithm. The repeating patterns are indentified and are indexed with number of times they occur, their position.

Lossy compression uses a compression algorithm that finds the unnecessary and redundant data in the file. This data is permanently removed from the file. This type of compression is mainly used on an image file or a sound file. Unnecessary data like colour depth, image resolution, sample rate and sample resolution.