Your knowledge and information power. Tips on wellness , health, id cards, fashion, shortcuts, technology, jobs, business, yoga, spirituality, interviews, cooking, travelling, places, photos, ethnic tribes, art, creativity

Monday, September 28, 2009

Basic Computer Maths

Basic Computer Math


Conversion of Numbers of Different Bases to Decimals

Consider the number 97531.

This is really: 9×10000 + 7×1000 + 5×100 + 3×10 + 1.

This can also be written as: 9×104 + 7×103 + 5×102 + 3×101 + 1×100.

There is nothing special about why we use base 10 except that humans have ten fingers.


In the world of electronics, the natural base is two, because it only has two states: on and off. We use “1” to signify on, and “0” to signify off. This is referred to as the “binary system.”

Example 1: Consider the binary number 1101011001.

To convert this to its decimal equivalent, we rewrite it as:
1×29 + 1×28 + 0×27 + 1×26 + 0× 25 + 1×24 + 1×23 + 0×22 + 0×21 + 1×20.

Or:
1×512 +1× 256 + 0×128 + 1×64 + 0×32 + 1×16 + 1×8 + 0×4 + 0×2 + 1 = 857.


Computational Devise “A”

Powers of 2 1024 512 256 128 64 32 16 8 4 2 1
Binary Digits 1 1 0 1 0 1 1 0 0 1
Their Product 512 256 0 64 0 16 8 0 0 1

Their sum: 512 + 256 + 0 + 64 + 0 + 16 + 8 + 0 + 0 + 1 = 857


Suppose we were to use another base, say “b.” That would mean that the numbers representing the amounts multiplying their powers would range from “0” to one less that the base, i.e. “b-1.” For example, in base ten, these numbers range from “0” to “9.” That is why in base two we only have “0” and “1.” The commonly used base in Information science is base sixteen, or hexadecimal (“hex” means six and “deci” refers to tenth).



Example 2: Consider the base four number (1023)4. Notice the numbers range between “0” and “3,” the subscript “4” indicates the base of the number.

1×43 0×42 + 2×41 + 3×40
1×64 + 0×16 + 2×8 + 3×1 = 73

Powers of 4 256 64 16 4 1
Base 4 Digits 1 0 2 3
Their Product 64 0 8 3

Adding the digits in the last row: 64 + 0 + 8 + 1 = 73


Example 3: (647)8

6×82 + 4×81 + 7×80
6×64 + 4×8 + 7×1 = 73

Powers of 8 512 64 8 1
Octal Digits 6 4 7
Their Product 384 24 7

The sum of the digits in the last row 384 + 24 + 7 = 73


Notice that we have chosen bases that are powers of two. Those are the numbers that followed the progression within computer science. Because it is more convenient to use higher bases to represent quantities because it requires less space, or slots, to do so. The final base that the computational progression settled on was base sixteen or hexadecimal. Using base16, the range of numbers multiplying the powers of the base have to range between “0” and “fifteen.” However, it was decided to represent the amounts from “ten” to “fifteen” by the letter A, B, C, D, E and F (i.e. A=10, B=11, C=12, D=13, C=14 and F=15).


Example 4: (D3)16


D×161 + 3×160
D×16 + 3×1 = 13×16 + 3×1 = 209

Most of the hexadecimal numbers used in computer math will only have two places, thus representing numbers from 0 to FF (or 0 to 255).

Conversion of Decimals Numbers to Different Bases

Consider the number 97531.

Computational Devise “B”

Base Divisor Dividend/Quotient Remainder
10 97531
10 9753 1
10 975 3
10 97 5
10 9 7
0 9

Check:

Powers of 1 100000 10000 1000 100 10 1
Decimal Digits 9 7 5 3 1
Their Product 90000 7000 500 30 1

The sum of the digits in the last row is:

90000 + 7000 + 500 + 30 +1 = 97531


Notice how when you divide each dividend the remainder is the quantity that multiplies the base to the next lower power. And when you have a quotient of “0” you have finished, and the final remainder is the quantity that multiplies the highest powered base.


Example 5: Convert the decimal number 25 to its binary equivalent.

Base Divisor Dividend/Quotient Remainder
2 25
2 12 1
2 6 0
2 3 0
2 1 1
0 1





Check:

Powers of 2 1024 512 256 128 64 32 16 8 4 2 1
Binary Digits 1 1 0 1 1
Their Product 16 8 0 0 1

The sum of the digits in the last row 16×1 + 1×8 + 0×4 + 1×2 + 1×1 = 25



Example 6: (48307)10

Base Divisor Dividend/Quotient Remainder
16 48307
16 3019 3
16 188 11
16 11 12 = C
16 0 11 = B

Check:

Powers of 16 4096 256 16 1
Hexadecimal Digits B = 11 C = 12 11 3
Their Product 45056 3072 176 3

Their sum 45056 + 3072 + 176 +3 = 48307














Hexadecimal Equivalents to the Decimal Numbers 0–255

Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex Dec Hex
0 0 32 20 64 40 96 60 128 80 160 A0 192 C0 224 E0
1 1 33 21 65 41 97 61 129 81 161 A1 193 C1 225 E1
2 2 34 22 66 42 98 62 130 82 162 A2 194 C2 226 E3
3 3 35 23 67 43 99 63 131 83 163 A3 195 C3 227 E3
4 4 36 24 68 44 100 64 132 84 164 A4 196 C4 228 E4
5 5 37 25 69 45 101 65 133 85 165 A5 197 C5 229 E5
6 6 38 26 70 46 102 66 134 86 166 A6 198 C6 230 E6
7 7 39 27 71 47 103 67 135 87 167 A7 199 C7 231 E7
8 8 40 28 72 48 104 68 136 88 168 A8 200 C8 232 E8
9 9 41 29 73 49 105 69 137 89 169 A9 201 C9 233 E9
10 A 42 2A 74 4A 106 6A 138 8A 170 AA 202 CA 234 EA
11 B 43 2B 75 4B 107 6B 139 8B 171 AB 203 CB 235 EB
12 C 44 2C 76 4C 108 6C 140 8C 172 AC 204 CC 236 EC
13 D 45 2D 77 4D 109 6D 141 8D 173 AD 205 CD 237 ED
14 E 46 2E 78 4E 110 6E 142 8E 174 AE 206 CE 238 EE
15 F 47 2F 79 4F 111 6F 143 8F 175 AF 207 CF 239 EF
16 10 48 30 80 50 112 70 144 90 176 B0 208 D0 240 F0
17 11 49 31 81 51 113 71 145 91 177 B1 209 D1 241 F1
18 12 50 32 82 52 114 72 146 92 178 B2 210 D2 242 F2
19 13 51 33 83 53 115 73 147 93 179 B3 211 D3 243 F3
20 14 52 34 84 54 116 74 148 94 180 B4 212 D4 244 F4
21 15 53 35 85 55 117 75 149 95 181 B5 213 D5 245 F5
22 16 54 36 86 56 118 76 150 96 182 B6 214 D6 246 F6
23 17 55 37 87 57 119 77 151 97 183 B7 215 D7 247 F7
24 18 56 38 88 58 120 78 152 98 184 B8 216 D8 248 F8
25 19 57 39 89 59 121 79 153 99 185 B9 217 D9 249 F9
26 1A 58 3A 90 5A 122 7A 154 9A 186 BA 218 DA 250 FA
27 1B 59 3B 91 5B 123 7B 155 9B 187 BB 219 DB 251 FB
28 1C 60 3C 92 5C 124 7C 156 9C 188 BC 220 DC 252 FC
29 1D 61 3D 93 5D 125 7D 157 9D 189 BD 221 DD 253 FD
30 1E 62 3E 94 5E 126 7E 158 9E 190 BE 222 DE 254 FE
31 1F 63 3F 95 5F 127 7F 159 9F 191 BF 223 DF 255 FF

Support This Site

Sign up for PayPal and start accepting credit card payments instantly.