Number Bases

From Compsci.ca Wiki

Revision as of 01:57, 1 April 2009 by Wtd (Talk | contribs)
Jump to: navigation, search

Contents

Number Bases

In math and computer science, numbers are often taken for granted, but understanding them is absolutely essential. The first thing to understand about numbers is how they're written, and for that we have to understand number bases.

Decimal

The base we're all raised on these days is base 10. We all know that in decimal representation "1" is one, "2" is two" and "456" is four hundred and fifty-six, but how does this actually work? How do we know that that "4" being where it indicate four hundred and how does the 5 being where it is indicate fifty?

In the case opf 456, we can see this as follows.

456 broken down
4 x 100 5 x 10 6 x 1

Of course, if you know anything about exponents, you should notice that there's a very simple pattern here.

456 broken down further
4 x 100 5 x 10 6 x 1
4 x 102 5 x 101 6 x 100

We can factor this out further

Factoring out the base
4 x 100 5 x 10 6 x 1
4 x 102 5 x 101 6 x 100
4 x b2 5 x b1 6 x b0
where b = 10

Now we should be able to extrapolate this pattern out to deal with decimal numbers of any length.

Binary

Binary is a very formal way of saying "base 2." In base 2 the only digits at our disposal for representations are 0 and 1. Let's break down a binary number.

Breakdown of 11001101
1 x 128 1 x 64 0 x 32 0 x 16 1 x 8 1 x 4 0 x 2 1 x 1
1 x 27 1 x 26 0 x 25 0 x 24 1 x 23 1 x 22 0 x 21 1 x 20
1 x b7 1 x b6 0 x b5 0 x b4 1 x b3 1 x b2 0 x b1 1 x b0
where b = 2
Equivalent Decimal Representation
128 64 0 0 8 4 0 1

When we add the decimal equivalents together using the addition we all know quite well, we get 205.

Hexidecimal

Also known as "base 16." Zero to nine are represented as one familiar with decimal would expect, while ten through fifteen are represented by A-F.

Breakdown of A9
A x 16 9 x 1
A x 161 9 x 160
A x b1 9 x b0
where b = 16
Equivalent Decimal Representation
160 9

The Obvious Pattern

The pattern here should be obvious. In number representations each digit represents that amount multipled by the base raised to the position of the digit from the right, starting from zero.

Personal tools