URI: http://www.j-a-b.net/web/numbersystem
last updated: 2009-12-04
© 2002-2009 Contact
The best known number system among the infinite number of possible systems is without doubt the decimal number system, the reason probably being that people usually have ten fingers to count with.
The position of a digit in a decimal number denotes how often the corresponding decimal power is present in the whole number. You should keep in mind, that any number to the power of Zero always equals One (x0=1).
| 1234 = | { | 1∙103 | + | 2∙102 | + | 3∙101 | + | 4∙100 |
| 1000 | + | 200 | + | 30 | + | 4 | ||
| 1234 | ||||||||
A computer does not have ten fingers to count with but has to fall back on some other intelligent mechanism for calculating numbers. The logic it uses defines two states, off and on, or 0 and 1. These two states can be easily expressed using binary numbers, which only use the digits 0 and 1. Here the position of the digit denotes how often the corresponding binary power is present in the whole number.
| 10011001 = | { | 1∙27 | + | 0∙26 | + | 0∙25 | + | 1∙24 | + | 1∙23 | + | 0∙22 | + | 0∙21 | + | 1∙20 |
| 128 | + | 0 | + | 0 | + | 16 | + | 8 | + | 0 | + | 0 | + | 1 | ||
| 153 | ||||||||||||||||
A single binary digit is known as 1bit in computer science. The above example, having eight digits can then be said to consist of 8bit. A unit of 4bit is usually called 1nybble (or nibble) and a unit of 8bit is called 1Byte.
Now binaries are something for geeks but the humble user is seldom confronted with them. Far more important and widespread throughout specifications are hexadecimal numbers, which are for example used for encoding colours and characters. A hexadecimal number may consist of the digits 0 to 9 and/or the letters a to f. This scope is sometimes called hexit in analogy to digit. In a hexadecimal number the position of a hexit denotes how often the corresponding hexadecimal power is present in the whole number. The letters a to f represent the decimal numbers 10 to 15 respectively and no distinction is made between uppercase or lowercase lettering.
| 2BA3 = | { | 2∙163 | + | B∙162 | + | A∙161 | + | 3∙160 |
| 2∙163 | + | 11∙162 | + | 10∙161 | + | 3∙160 | ||
| 8192 | + | 2816 | + | 160 | + | 3 | ||
| 11171 | ||||||||
Using hexadecimal numbers has one great advantage, which is, nybbles and bytes can be easily expressed as hexadecimal numbers:
| nybble | Hex | nybble | Hex |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0001 | 1 | 1001 | 9 |
| 0010 | 2 | 1010 | A |
| 0011 | 3 | 1011 | B |
| 0100 | 4 | 1100 | C |
| 0101 | 5 | 1101 | D |
| 0110 | 6 | 1110 | E |
| 0111 | 7 | 1111 | F |
As one byte is made up of two nybble, the only thing you have to do is take the corresponding nybble from the former table to get the corresponding hexadecimal number. Consider the byte with value 10010010 (decimal 128+16+2=146). It consits of nybble 1001 and 0010. Its corresponding hexadecimal value is thus 92.
This allows for easy handling of numbers, which are large and complicated in decimal and binary systems. Example:
1111111111111111bin = 65535dec = FFFFhex
For the sake of completeness octal numbers shall be mentioned as well, as one might encounter these from time to time. Octal numbers consist of the digits 0 to 7 and follow the same rules as the above mentioned systems, that is, the digits represent the factors of octal powers.
| 63571 = | { | 6∙84 | + | 3∙83 | + | 5∙82 | + | 7∙81 | + | 1∙80 |
| 6∙4096 | + | 3∙512 | + | 5∙64 | + | 7∙8 | + | 1∙1 | ||
| 24576 | + | 1536 | + | 320 | + | 56 | + | 1 | ||
| 26489 | ||||||||||
Octal numbers can be used to simplify bitstrings in a way like hexadecimal numbers do. Instead of 4bit an octal number can represent 3bit as shown in the following table:
| 3bit | Oct |
|---|---|
| 000 | 0 |
| 001 | 1 |
| 010 | 2 |
| 011 | 3 |
| 100 | 4 |
| 101 | 5 |
| 110 | 6 |
| 111 | 7 |
Thus long binaries may be expressed by their corresponding octal values like the following example shows:
111111111111111bin = 32767dec = 77777oct
The subsequent chart lists decimal numbers 0 to 255 with their corresponding hexadecimal values. These are used very often as they represent all 256 possible byte values and thus correspond to the 256 possible values the basic colours red, green, and blue can have in the 24bit RGB colour-space and, moreover, they are used to encode the extended ASCII charset.
| DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX | DEC | HEX |
| 000 | 00 | 001 | 01 | 002 | 02 | 003 | 03 | 004 | 04 | 005 | 05 | 006 | 06 | 007 | 07 |
| 008 | 08 | 009 | 09 | 010 | 0A | 011 | 0B | 012 | 0C | 013 | 0D | 014 | 0E | 015 | 0F |
| 016 | 10 | 017 | 11 | 018 | 12 | 019 | 13 | 020 | 14 | 021 | 15 | 022 | 16 | 023 | 17 |
| 024 | 18 | 025 | 19 | 026 | 1A | 027 | 1B | 028 | 1C | 029 | 1D | 030 | 1E | 031 | 1F |
| 032 | 20 | 033 | 21 | 034 | 22 | 035 | 23 | 036 | 24 | 037 | 25 | 038 | 26 | 039 | 27 |
| 040 | 28 | 041 | 29 | 042 | 2A | 043 | 2B | 044 | 2C | 045 | 2D | 046 | 2E | 047 | 2F |
| 048 | 30 | 049 | 31 | 050 | 32 | 051 | 33 | 052 | 34 | 053 | 35 | 054 | 36 | 055 | 37 |
| 056 | 38 | 057 | 39 | 058 | 3A | 059 | 3B | 060 | 3C | 061 | 3D | 062 | 3E | 063 | 3F |
| 064 | 40 | 065 | 41 | 066 | 42 | 067 | 43 | 068 | 44 | 069 | 45 | 070 | 46 | 071 | 47 |
| 072 | 48 | 073 | 49 | 074 | 4A | 075 | 4B | 076 | 4C | 077 | 4D | 078 | 4E | 079 | 4F |
| 080 | 50 | 081 | 51 | 082 | 52 | 083 | 53 | 084 | 54 | 085 | 55 | 086 | 56 | 087 | 57 |
| 088 | 58 | 089 | 59 | 090 | 5A | 091 | 5B | 092 | 5C | 093 | 5D | 094 | 5E | 095 | 5F |
| 096 | 60 | 097 | 61 | 098 | 62 | 099 | 63 | 100 | 64 | 101 | 65 | 102 | 66 | 103 | 67 |
| 104 | 68 | 105 | 69 | 106 | 6A | 107 | 6B | 108 | 6C | 109 | 6D | 110 | 6E | 111 | 6F |
| 112 | 70 | 113 | 71 | 114 | 72 | 115 | 73 | 116 | 74 | 117 | 75 | 118 | 76 | 119 | 77 |
| 120 | 78 | 121 | 79 | 122 | 7A | 123 | 7B | 124 | 7C | 125 | 7D | 126 | 7E | 127 | 7F |
| 128 | 80 | 129 | 81 | 130 | 82 | 131 | 83 | 132 | 84 | 133 | 85 | 134 | 86 | 135 | 87 |
| 136 | 88 | 137 | 89 | 138 | 8A | 139 | 8B | 140 | 8C | 141 | 8D | 142 | 8E | 143 | 8F |
| 144 | 90 | 145 | 91 | 146 | 92 | 147 | 93 | 148 | 94 | 149 | 95 | 150 | 96 | 151 | 97 |
| 152 | 98 | 153 | 99 | 154 | 9A | 155 | 9B | 156 | 9C | 157 | 9D | 158 | 9E | 159 | 9F |
| 160 | A0 | 161 | A1 | 162 | A2 | 163 | A3 | 164 | A4 | 165 | A5 | 166 | A6 | 167 | A7 |
| 168 | A8 | 169 | A9 | 170 | AA | 171 | AB | 172 | AC | 173 | AD | 174 | AE | 175 | AF |
| 176 | B0 | 177 | B1 | 178 | B2 | 179 | B3 | 180 | B4 | 181 | B5 | 182 | B6 | 183 | B7 |
| 184 | B8 | 185 | B9 | 186 | BA | 187 | BB | 188 | BC | 189 | BD | 190 | BE | 191 | BF |
| 192 | C0 | 193 | C1 | 194 | C2 | 195 | C3 | 196 | C4 | 197 | C5 | 198 | C6 | 199 | C7 |
| 200 | C8 | 201 | C9 | 202 | CA | 203 | CB | 204 | CC | 205 | CD | 206 | CE | 207 | CF |
| 208 | D0 | 209 | D1 | 210 | D2 | 211 | D3 | 212 | D4 | 213 | D5 | 214 | D6 | 215 | D7 |
| 216 | D8 | 217 | D9 | 218 | DA | 219 | DB | 220 | DC | 221 | DD | 222 | DE | 223 | DF |
| 224 | E0 | 225 | E1 | 226 | E2 | 227 | E3 | 228 | E4 | 229 | E5 | 230 | E6 | 231 | E7 |
| 232 | E8 | 233 | E9 | 234 | EA | 235 | EB | 236 | EC | 237 | ED | 238 | EE | 239 | EF |
| 240 | F0 | 241 | F1 | 242 | F2 | 243 | F3 | 244 | F4 | 245 | F5 | 246 | F6 | 247 | F7 |
| 248 | F8 | 249 | F9 | 250 | FA | 251 | FB | 252 | FC | 253 | FD | 254 | FE | 255 | FF |
The converter translates decimal, octal, hexadecimal and binary numbers into each
other. The decimal input value is limited and not allowed to be greater than
231-1 = 2147483647. There is also a
popup-version
available for independent use outside this page's context.