In order to be able to fully understand information representations, we need to understand some basic (and not so basic) mathematical methods and techniques. If math is not your strong suit, please do not panic. You should make the most of the time in the lab sessions to make sure you understand these techniques. Conversely, if you already know about these, please don't get bored: you should learn new things in the process

The topics covered are (links go to Wikipedia pages for background information):

The base of a positional number system tells us how many digits (symbols) there are for each position in a number. For example, in our usual base 10, we have 10 digits (0123456789). If we want to represent a number greater than 9, we need a new position (10,11,12,13,14,15,16,17.18,19...). We're so familiar with Base 10 that we don't think about it - but it's really only one example of a number system. Note that this only applies to a positional number system - other systems (such as Roman numerals) are not positional (but the Roman system is still inherently Base 10).

Exponents & Logarithms

An exponent is simply a shorthand mathematical representation for multiplying a number by itself a given number of times. For example, an exponent of 2 ("squared') means multiply a number by itself: a*a. An exponent of 3 ("cubed") means multiply a number by itself again: a*a*a. Thus exponentation is a mathematical function that can be applied to a number. Mathematicians talk of "raising a number" to an exponent or that something is "to the power". The exponent is indicated using a superscript typeface or sometimes the symbol ^ (as in 10^5).

A logarithm is the reverse function of the exponent: it is the number a given number has to be rasied to to give a third number.

Remember this:

10 is the base 2 is the exponent

So what???

The rounded-up log of a number x tells you how many digits you need to represent that many things (e.g. numbers 0..x-1) in a given base. For example...

You need 2 (decimal) digits to represent 100 numbers (00..99) in base 10
If you want to represent 368 numbers in base 10, you need how many digits?
Log10(368) = 2.566 (to 3 d.p. - see online calculator for calculating logs) - round up - you need 3 digits
You need 2 (decimal) digits to represent the 50 states of America
You need 9 (decimal) digits to uniquely identify each resident of the USA (307,006,550 July 2009)

Binary Numbers

"There are only 10 types of people in the world: those who understand binary, and those who don't"

Using binary is an attempt to accommodate the computer's way of working instead of ours (10 fingers) - see http://www.kerryr.net/pioneers/binary.htm . The transistor, the basis of semiconductor chips, has two states - on or off (or high voltage, low voltage). These two states represent two digits - 0 and 1.

Binary is very simply a positional number system with just these two digits. Below is a translation between Decimal (Base 10) numbers 0-10 and Binary (Base 2) numbers:

This is the origin of the term Bits -- it's short for Binary Digits.

So here's a question... how many bits are needed to represent the numbers 0..15 (in decimal) ?
How many bits are needed to represent the numbers 0...368 (in decimal) ?
How many bits are needed to represent the following: (apples, oranges, bananas, custard, cream)?
How many bits are needed to represent the letters A-Z?

Now a Byte is 8 bits (usually) ... how many different things can you represent in a Byte?

Conversion from Binary to Decimal is quite easy - since each position has value 2^n (where n is the bit number, starting with 0 at the rightmost bit) we simply sum the values of the columns' values which have 1's in.

Conversion from Decimal to Binary requires building a binary string from right to left, iteratively dividing the decimal number by 2 and putting a "1" in the column if there is a remainder (uneven number you are dividing) or "0" if not, ending when the result is 0. For example:

35/2 = 17 r 1 xxxxxx1
17/2 = 8 r 1 xxxxx11
8/2 = 4 r 0 xxxx011
4/2 = 2 r 0 xxx0011
2/2 = 1 r 0 xx00011
1/2 = 0 r 1 x100011 So 35 in binary is 100011
6/2 = 3 r 0 xxxxxx0
3/2 = 1 r 1 xxxxx10
1/2 = 0 r 1 xxxx110 So 6 in binary is 110

Hexadecimal Numbers

So this is easy.... we can do any base we like now. How about base 16? That's called hexadecimal notation. So you just need 16 digits - 0,1,2,3,4,5,6,7,8,9.... but what then? Well convention has it we use the letters A-F. And that's it. Here's an updated table with Binary, Decimal and Hexadecimal (Hex) numbers up to 30:

So how many states are there in the U.S. (in Hex?)

Who cares? Well hex turns out to be a compact representation that aligns better with binary (because 2^4 is 16). For example two hex digits can represent all of the numbers in a byte. For this reason, it is often used in technical representations in computing, often hidden, but sometimes not (e.g. RGB values in colors).

Examples:
Hex color for crimson is #990000, and Hex color for cream is #FEFEEA Ethernet "MAC" address is usually 48 bits (6 bytes) but usually represented as 12 Hex digits: 00:60:17:9A:1E:6F

In order to be able to fully understand information representations, we need to understand some basic (and not so basic) mathematical methods and techniques. If math is not your strong suit, please do not panic. You should make the most of the time in the lab sessions to make sure you understand these techniques. Conversely, if you already know about these, please don't get bored: you should learn new things in the process

The topics covered are (links go to Wikipedia pages for background information):

Three related ideas: Bases, Logarithms and Exponents

Binary numbers - Base 2!

Units - Bits and Bytes

Hexadecimal Numbers

Summation

## Bases

The base of a positional number system tells us how many digits (symbols) there are for each position in a number. For example, in our usual base 10, we have 10 digits (0123456789). If we want to represent a number greater than 9, we need a new position (10,11,12,13,14,15,16,17.18,19...). We're so familiar with Base 10 that we don't think about it - but it's really only one example of a number system. Note that this only applies to a positional number system - other systems (such as Roman numerals) are not positional (but the Roman system is still inherently Base 10).

## Exponents & Logarithms

An exponent is simply a shorthand mathematical representation for multiplying a number by itself a given number of times. For example, an exponent of 2 ("squared') means multiply a number by itself: a*a. An exponent of 3 ("cubed") means multiply a number by itself again: a*a*a. Thus exponentation is a mathematical function that can be applied to a number. Mathematicians talk of "raising a number" to an exponent or that something is "to the power". The exponent is indicated using a superscript typeface or sometimes the symbol ^ (as in 10^5).

A logarithm is the reverse function of the exponent: it is the number a given number has to be rasied to to give a third number.

## Remember this:

10 is the base2 is the exponentSo what???The rounded-up log of a number x tells you how many digits you need to represent that many things (e.g. numbers 0..x-1) in a given base. For example...

You need 2 (decimal) digits to represent 100 numbers (00..99) in base 10

If you want to represent 368 numbers in base 10, you need how many digits?

Log10(368) = 2.566 (to 3 d.p. - see online calculator for calculating logs) - round up - you need 3 digits

You need 2 (decimal) digits to represent the 50 states of America

You need 9 (decimal) digits to uniquely identify each resident of the USA (307,006,550 July 2009)

## Binary Numbers

"There are only 10 types of people in the world: those who understand binary, and those who don't"

Binary numbers - Base 2!

Using binary is an attempt to accommodate the computer's way of working instead of ours (10 fingers) - see http://www.kerryr.net/pioneers/binary.htm . The transistor, the basis of semiconductor chips, has two states - on or off (or high voltage, low voltage). These two states represent two digits - 0 and 1.

Binary is very simply a positional number system with just these two digits. Below is a translation between Decimal (Base 10) numbers 0-10 and Binary (Base 2) numbers:

This is the origin of the term Bits -- it's short for Binary Digits.

So here's a question... how many bits are needed to represent the numbers 0..15 (in decimal) ?

How many bits are needed to represent the numbers 0...368 (in decimal) ?

How many bits are needed to represent the following: (apples, oranges, bananas, custard, cream)?

How many bits are needed to represent the letters A-Z?

Now a Byte is 8 bits (usually) ... how many different things can you represent in a Byte?

Conversion from Binary to Decimalis quite easy - since each position has value 2^n (where n is the bit number, starting with 0 at the rightmost bit) we simply sum the values of the columns' values which have 1's in.Conversion from Decimal to Binaryrequires building a binary string from right to left, iteratively dividing the decimal number by 2 and putting a "1" in the column if there is a remainder (uneven number you are dividing) or "0" if not, ending when the result is 0. For example:## Hexadecimal Numbers

So this is easy.... we can do any base we like now. How about base 16? That's called hexadecimal notation. So you just need 16 digits - 0,1,2,3,4,5,6,7,8,9.... but what then? Well convention has it we use the letters A-F. And that's it. Here's an updated table with Binary, Decimal and Hexadecimal (Hex) numbers up to 30:

So how many states are there in the U.S. (in Hex?)

Who cares? Well hex turns out to be a compact representation that aligns better with binary (because 2^4 is 16). For example two hex digits can represent all of the numbers in a byte. For this reason, it is often used in technical representations in computing, often hidden, but sometimes not (e.g. RGB values in colors).

Examples:

Hex color for crimson is #990000, and Hex color for cream is #FEFEEA

Ethernet "MAC" address is usually 48 bits (6 bytes) but usually represented as 12 Hex digits: 00:60:17:9A:1E:6F