Introduction to Math for computer programming

This page is currently only a very very small fraction of what I intend it to be. If you have idea for topics or the heavenly inspiration to contribute something great to this topic: Please click that "edit" button and do it!

Please try to keep this simple and easy to understand without prior knowledge of anything beyond introductory algebra unless the topic warrants it. If you know calculus: Good for you. That doesn't mean the average viewer of this page does.

Number systems
The following is a list of common number systems. The names of which are derived from latin.


 * Unary is of very limited usefulness since only positive integers can be expressed in it. The same is more-or-less true for any numbering system whose absolute value is equal to one.
 * Binary is used to portray the specific values of on (1) and off (0) used in digital electronics like computers
 * Octal was more commonly used in the early days of computing and especially on computers whose byte size was divisible by three. It is still used in some computing cultures and for some specific purposes but its use has been largely supplanted by hexadecimal.
 * Hexadecimal is often used to portray binary numbers in a smaller, neater-seeming form

Determining number value
Because people tend to be most familiar with dealing with numbers in Decimal, that is the basis we will use to get a feel for a number's value.

You may determine the decimal value of a number in any given base using the following formula:

Where:
 * K = Decimal value of a given number
 * d = Decimal value of a value in a specified base
 * B = Decimal value of the base of the number being evaluated
 * i = Decimal value of the index at which the number currently being evaluated is located (0 = right-most; 1, 2, 3, etc. are 1, 2, 3, etc. places from the right-most)

In this scheme, the right-most digit in any number in any base is:
 * The digit place with the smallest potential value
 * Has an index (i) value of 0

It is common to determine the value of a number, starting with the right-most value. That's what I'm going to be doing in the following examples.

Converting decimal to decimal
Converting the decimal number 931 to decimal: 1 * 10^0 =  1 3 * 10^1 =  30 9 * 10^2 = 900 900 + 30 + 1 = 931

Converting the decimal number 23 to decimal: 3 * 10^0 = 3 2 * 10^1 = 20 20 + 3 = 23

Converting binary to decimal
Converting the binary number 0b01001100 to decimal: 0b00000000 = 0 * 2^0 = 0 0b00000000 = 0 * 2^1 = 0 0b00000100 = 1 * 2^2 = 4 0b00001000 = 1 * 2^3 = 8 0b00000000 = 0 * 2^4 = 0 0b00000000 = 0 * 2^5 = 0 0b01000000 = 1 * 2^6 = 64 0b00000000 = 0 * 2^7 = 0 64 + 8 + 4 = 76

Converting the binary number 0b11111111 to decimal: 0b00000001 = 1 * 2^0 =  1 0b00000010 = 1 * 2^1 =  2 0b00000100 = 1 * 2^2 =  4 0b00001000 = 1 * 2^3 =  8 0b00010000 = 1 * 2^4 = 16 0b00100000 = 1 * 2^5 = 32 0b01000000 = 1 * 2^6 = 64 0b10000000 = 1 * 2^7 = 128 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

Converting hexadecimal to decimal
Converting the hexadecimal number 0x16 to decimal: 6 * 16^0 = 6 1 * 16^1 = 16 16 + 6 = 22

Converting the hexadecimal number 0xBEEF to decimal: F = 15 * 16^0 =    15 E = 14 * 16^1 =   224 E = 14 * 16^2 = 3,584 B = 11 * 16^3 = 45,056 45,056 + 3,584 + 224 + 15 = 48,879

Binary
Binary relys on only two digits which are usually written 0 and 1, but are easilly encoded as "off" and "on" in switch circuits, which makes Binary the language of choice in low-level Computing and Digital Electronics.

Hexadecimal
Hexadecimal is commonly used to represent binary data, as it occupies only one quarter of the space when written down.

Corollary
In all number systems, prefixed zeros can be ignored (do not affect the value represented), however common practice is to prefix all octal numbers with a leading 0 (zero), all hexadecimal values with 0x and all binary numbers with zeros so that it contains a number of digits which is divisible by eight.