# 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:

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

## Warnings:

• Beware when you prefix decimal values with a zero character. You may want to justify a column of figures. If you add leading zero characters to a numeric string, if that string is subsequently parsed back to a numeric value, you may inadvertently export the value as a decimal but import it as an octal value. This can lead to an extremely difficult to diagnose fault in your software because the parsers sometimes add some intelligence and will correctly interpret the value as decimal if the characters 8 or 9 are present but otherwise interpret it as octal notation.

• Be careful that you remove any leading zero characters from the text strings that you plan to convert using the numeric parser.

• This may be implementation dependent behavior to some extent.

## Example code:

```   <HTML>
<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);

myOctal         = ii.toString(8);

myHex           = ii.toString(16);

myChar          = String.fromCharCode(ii);

document.write("<TR ALIGN=RIGHT><TD>");
document.write(ii);
document.write("</TD><TD>");
document.write("</TD><TD>");
document.write("</TD><TD>");
document.write("</TD><TD>");
document.write("&nbsp;"+myChar);
document.write("</TD></TR>");
}
document.write("</TABLE>");
</SCRIPT>
</BODY>
</HTML>```