# Octal value (Definition)

A numeric value based on a radix of 8.

Availability:

 ECMAScript edition - 3

An octal value is an integer composed of only the following characters:

0 1 2 3 4 5 6 7

Octal values are always prefixed by a zero character.

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

00 01 02 03 04 05 06 07 010 011 012

Octal values have a historical significance from having been used in the earliest computer systems. However these days, they are particularly useful since they map quite conveniently to the binary system. Each octal digit corresponds to three binary digits.

The most significant of the three octal digits does not have a full range since it contains a carry over bit and a three digit octal number actually represents a 9 bit value. However, an 8 bit value can be encoded conveniently if the range is limited to 0377 as a maximum. Hexadecimal values map far more conveniently although they are harder to compute mentally.

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

• This may be implementation-dependant behavior to some extent.

• Be careful that you remove any leading zero characters from the text strings that you plan to convert using the numeric parser. The example shows a simple function for doing this.

## Example code:

```   <HTML>
<BODY>
<SCRIPT>
myString = "00123";
// Strip leading zero characters off a numeric string
{
return aString.substr(aString.search(/[1-9]/));
}
</SCRIPT>
</BODY>
</HTML>```