Decimal value (Definition)

A numeric value based on a radix of 10.

A decimal value is an integer composed of only the following characters:

0 1 2 3 4 5 6 7 8 9

Decimal values are never prefixed by a zero character.

The sequence carries over for the next increment when each column reaches the value 9. Thus:

0 1 2 3 4 5 6 7 8 9 10 11 12

Converting between decimal, hexadecimal, and binary values is quite complicated. Here are the first 16 values in all number bases:

BinaryOctalDecimalHexadecimal
00000000
00010111
00100222
00110333
01000444
01010555
01100666
01110777
10001088
10011199
10101210A
10111311B
11001412C
11011513D
11101614E
11111715F

Warnings:

Example code:

   <HTML>
   <HEAD>
   </HEAD>
   <BODY>
   <SCRIPT>
   // Create a 0-255 lookup table
   document.write("<TABLE BORDER=1>");
   document.write("<TR><TH>Index</TH>");
   document.write("<TH>Binary</TH>");
   document.write("<TH>Octal</TH>");
   document.write("<TH>Hex</TH>");
   document.write("<TH>Char</TH></TR>");
   for(ii=0; ii<256; ii++)
   {
   myBinary        = ii.toString(2);
   myBinaryPadding = "00000000".substr(1,(8-myBinary.length));
   
   myOctal         = ii.toString(8);
   myOctalPadding  = "0000".substr(1,(4-myOctal.length));
   
   myHex           = ii.toString(16);
   myHexPadding    = "00".substr(1,(2-myHex.length));
   
   myChar          = String.fromCharCode(ii);
   
   document.write("<TR ALIGN=RIGHT><TD>");
   document.write(ii);
   document.write("</TD><TD>");
   document.write(myBinaryPadding+myBinary);
   document.write("</TD><TD>");
   document.write(myOctalPadding+myOctal);
   document.write("</TD><TD>");
   document.write(myHexPadding+myHex.toUpperCase());
   document.write("</TD><TD>");
   document.write("&nbsp;"+myChar);
   document.write("</TD></TR>");
   }
   document.write("</TABLE>");
   </SCRIPT>
   </BODY>
   </HTML>

See also:Hexadecimal value, Integer constant, Number.toString(), Octal value