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|
|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 0s 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|
|To the power of||27||26||25||24||23||22||21||20|
8-bit bytes can be divided into two 4 bit parts called Nibbles . ..
|1st nibble||2nd nibble|
A nibble can represent 16 numbers, from 0 to 15.
In binary, the smallest possible number an 8-bit byte can represent = 00000000 (8 zeros) , or 0 in decimal.
The biggest number an 8-bit byte can represent = 11111111 (8 ones) 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 ..
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 ..
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 ..
This is an example of a hex number ..
|Possible digits 0 to 9 and A to F||F||3|
|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.