settings
skip menu
change media type
xhtml+xml
change language
deutsch
scripting
dec -> hex

URI: http://www.j-a-b.net/web/numbersystem
last updated: 2009-12-04
© 2002-2009 Contact

up down

Number Systems

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).

Example for decimal number 1234
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.

Example of converting binary 10011001 to decimal number 153
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.

Example of converting hexadecimal number 2BA3 to decimal number 11171
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:

Relationship between nybbles and hexadecimal numbers
nybbleHexnybbleHex
0000010008
0001110019
001021010A
001131011B
010041100C
010151101D
011061110E
011171111F

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.

Example of converting octal number 63571 to decimal number 26489
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:

Relationship between 3bit binaries and octal numbers
3bitOct
0000
0011
0102
0113
1004
1015
1106
1117

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.

Decimal Numbers 0-255 ↔ Hexadecimal Numbers 00-FF
DECHEXDECHEXDECHEXDECHEX DECHEXDECHEXDECHEXDECHEX
DECHEXDECHEXDECHEXDECHEX DECHEXDECHEXDECHEXDECHEX
00000001010020200303 00404005050060600707
00808009090100A0110B 0120C0130D0140E0150F
01610017110181201913 02014021150221602317
02418025190261A0271B 0281C0291D0301E0311F
03220033210342203523 03624037250382603927
04028041290422A0432B 0442C0452D0462E0472F
04830049310503205133 05234053350543605537
05638057390583A0593B 0603C0613D0623E0633F
06440065410664206743 06844069450704607147
07248073490744A0754B 0764C0774D0784E0794F
08050081510825208353 08454085550865608757
08858089590905A0915B 0925C0935D0945E0955F
09660097610986209963 10064101651026610367
10468105691066A1076B 1086C1096D1106E1116F
11270113711147211573 11674117751187611977
12078121791227A1237B 1247C1257D1267E1277F
12880129811308213183 13284133851348613587
13688137891388A1398B 1408C1418D1428E1438F
14490145911469214793 14894149951509615197
15298153991549A1559B 1569C1579D1589E1599F
160A0161A1162A2163A3 164A4165A5166A6167A7
168A8169A9170AA171AB 172AC173AD174AE175AF
176B0177B1178B2179B3 180B4181B5182B6183B7
184B8185B9186BA187BB 188BC189BD190BE191BF
192C0193C1194C2195C3 196C4197C5198C6199C7
200C8201C9202CA203CB 204CC205CD206CE207CF
208D0209D1210D2211D3 212D4213D5214D6215D7
216D8217D9218DA219DB 220DC221DD222DE223DF
224E0225E1226E2227E3 228E4229E5230E6231E7
232E8233E9234EA235EB 236EC237ED238EE239EF
240F0241F1242F2243F3 244F4245F5246F6247F7
248F8249F9250FA251FB 252FC253FD254FE255FF

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 popuppopup-version available for independent use outside this page's context.

DOHB-Converter (limit: 231-1)






CC logo
This page is licensed under a Creative Commons License.