In part one of Computer Math, I explained the virtues of binary and ended with the following questions:

Who uses these numbers for anything when I can just type the letter A? And by the way, computers do more than just splash letters on the screen, buddy.
This is where Hex and Assembly language come into play.

In math and computer science, Hex is a numeric system with sixteen symbols, or digits, as opposed to the ten used in the traditional decimal numeric system.

• Decimal - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
• Hexadecimal - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (A-F represent values from 10-15.)
• Binary - 0, 1

### Why 16 digits?

Each hex digit represents four binary digits, or bits. The main reason for using hex is because it is more human-friendly than binary. In binary, the highest four bit number is 1111, or 15. 0-15 = 16 digits. Hex is based on 16 digits for this reason. Look at the table below for the differences:

10110000     01100001  B0     61  176     97

### Why not use Decimal? That's the easiest of them all?

Hex works better because one digit in hex represents a nibble, which is half of an octet, or byte (8 bits). For example, byte values can range from 0 to 255, in decimal format (remember that number?), but are more easily represented as two hex digits in the range 00 to FF. Hex is also used to represent computer memory addresses.

### Assembly language

Assembly language and machine language are considered "low-level" programming languages because these languages deal directly with the computer's architecture. In other words, it's hard. A high-level language, like Visual Basic or C, is built using a low-level language and is made easier to use by incorporating more "human" elements.

Look at this line of assembly code and let's examine what this is and how we got here:

MOV AL, 61h

Below, the binary numbers, 10110000 01100001, are `translated to their Hex representations, B0 61, and then from Hex to an assembly language mnemonic. From Hex, B0 translates to assembly as the MOV mnemonic. `Therefore, the previous line of assembly language code means, "'Move a copy of the following value into AL," and `61` is a hex representation of the value 01100001, which is 97 in decimal format.

10110000     01100001 B0     61 MOV AL, 61h

To sum up:

10110000 01100001 = B0 61 = MOV AL, 61h = Move a copy of 97 to this place in memory.

Examine the code below. The code below is written in two low-level languages (Machine (Hex) and Assembly) and one high-level language (C). This code calculates the nth Fibonacci number, which is a number defined as being the sum of the two previous numbers in the series (1, 1, 2, 3, 5, 8, 13, 21...) Binary numbers are converted to Hex which gives you the "code" for the Fibonacci function in the first column. Translate the Hex into assembly mnemonics and you get the second column.

.

## SolarWinds Subnet Calculator

As you can see from the illustration below, Hex and binary are used in the real world. This is a screen grab from SolarWinds' Subnet Calculator. Fortunately for you, this is a free tool.

Brain hurt yet?