Free technical help for digital creators - music, video, art, photography, graphic & web design

Computer counting systems by Matt Ottewill

Digital systems (such as computers, mobile phones, DVD players etc) use a digital (binary) code of 1s and 0s to represent operating systems, applications and data. You can read more about the physical forms binary takes here. This page explains how binary bits (1s and 0s) are combined to create larger and more meaningful units which in turn represent complex information and data.

Denary / decimal (base 10)

This is our everyday counting system. Here is an example, the decimal number 5126 ..

Possible digits 0-9 5 1 2 6
Units 1000's 100's 10's 1's
To the power of 103 102 101 100

Before decimalisation in the UK we used base 12 (imperial) derived from the seasons and the phases of the moon.

Binary (base 2)

Base 2 uses only 0’s and 1's. Computers use this. Early computers employed simple switches (electro magnets relays closed and released/opened) to represent 0's and 1's. Then came vacuum tubes followed by transistors. Binary is the obvious counting base for computers.

Early computers had an 8-bit architecture. This means they were able to calculate one 8-digit number at a time. These 8-digit numbers are called Bytes.

Each individual digit of a Bytes is called a Bit.

Here is an example of an 8-bit byte. The number represented is decimal 218 ..

Possible digits 0 or 1 1 1 0 1 1 0 1 0
Units 128's 64's 32's 16's 8's 4's 2's 1's
To the power of 27 26 25 24 23 22 21 20

Nibbles

8-bit bytes can be divided into two 4 bit parts called Nibbles . ..

1st nibble 2nd nibble
1 1 0 1 1 0 1 0

A nibble can represent 16 numbers, from 0 to 15.

Binary Decimal
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
1000 8
1001 9
1010 10
1011 11
1100 12
1101 13
1110 14
1111 15

Byte values

In binary, the smallest possible number an 8-bit byte can represent = 00000000 (8 zero’s) , or 0 in decimal.

The biggest number an 8-bit byte can represent = 11111111 (8 one’s) or 255 in decimal.

Incidentally, 1024 Bytes = 1 kilobyte (1K). 1024K (roughly a million bytes) = 1 megabyte (1mb).

MSB and LSB

In a binary, the bit furthest to the left is known as the most significant bit (MSB) and the bit furthest to the right is known as the least significant bit (LSB).

The MSB is used to identify (or sign-post) what kind of byte it is. For example:

In the MIDI language, MIDI messages are comprised of a number of bytes. A single status byte is followed by one or more data bytes.

A byte with an MSB of 1 indicates a status byte. These bytes define what the message is, such as change the sound volume.

A byte with an MSB of 0 indicates a data byte. These bytes carry data values.

For example ..

10011001 01101011

Hexadecimal (base 16)

Hexadecimal makes it possible to represent large binary and decimal numbers with fewer characters. It can work like shorthand. Hexadecimal is often referred to as Hex. When we discuss or write down Hex numbers we put an H after them so we know they are hex. Here are some examples ..

Hexadecimal Decimal equivalent
16H 21
56H 86
B9H 185
FFH 255

In hex the numbers 0 to 9 are represented with numbers, but above 9 they are represented with letters. So ..

  • the symbols "0"–"9" represent values 0 to 9
  • the symbols "A"–"F" to represent values from 10 to 15

Here is a partial decimal to 8-bit binary to hex conversion chart ..

Decimal Binary Hexadecimal (hex)
0 00000000 0H
1 00000001 1H
2 00000010 2H
3 00000011 3H
4 00000100 4H
5 00000101 5H
6 00000110 6H
7 00000111 7H
8 00001000 8H
9 00001001 9H
10 00001010 AH
11 00001011 BH
12 00001100 CH
13 00001101 DH
14 00001110 EH
15 00001111 FH

This is an example of a hex number ..

Possible digits 0 to 9 and A to F F 3
Units 16's 1's
To the power of 161 00

In this example the hex number is F(15) x 16 + 3 x 1 which equals 243 in decimal, or F3h in hex. You can see that we have converted a 3 digit number into 2 digits.

The biggest number hex can express in 2 columns (or bits) is FFH (15 x 16 + 15) = 255 in decimal.

Biggest number in 8 bit binary = 11111111 = 255.

Thus a 2 bit hex number can represent any 8 bit binary byte.

 

MIDI (Musical Instrument Digital Interface) & Hexadecimal

8-bit languages are relative primitive by today’s standards, but they are useful to study when trying to understand how binary and hex works.

MIDI is an example of an 8-bit language. It is used by music makers. It allows an interconnected network of electronic musical instruments and computers to be connected together. Find out more here

MIDI users (musicians for example) do not input and edit MIDI data with computers at binary level. When they change MIDI value parameters (such as volume) in applications such as Logic or Cubase, they use decimal. Logic and Cubase can record, edit and replay MIDI.

If you think about it, Logic and Cubase are nothing more than applications designed to record edit, replay and store MIDI events, whilst presenting them to the end user graphically and numerically in a familiar counting base (ie decimal). But under the hood its all binary (1s and 0s). (They also handle audio of course).

Because MIDI is tied to a hardware specification (ports, cables and hardware devices such as keyboards etc) it has remained an 8-bit language. Other software elements in a computer system may be 16, 24, 32 or 64-bit. Click here to read more.

Hex is base 16. Because MIDI is an 8-bit language (nice and simple to understand!) its ideal to study when trying to understand how hex works. In fact MIDI is often displayed in hex to make editing and manipulation of some MIDI commands easier to understand (such as Systems Exclusive).

Between the decimal interface of Logic or Cubase, and the underlying binary computer machine code, MIDI can be manipulated with the more succinct and convenient counting base of hex. To facilitate the control of systems exclusive messages sequencers often have screens/pages where MIDI data is presented in hex form.

Every 8-bit MIDI value can be expressed by a 2 digit hex number. For example; the MIDI byte 10010011 is 147 in decimal or 93H in hex.