Hexadecimal value (Definition)

A numeric value based on a radix of 16.

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

0 1 2 3 4 5 6 7 8 9


a b c d e f

Note the use of the alphabetic characters to extend the decimal number digit set.

Hexadecimal values are always prefixed by a zero and X character.

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

0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07

0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F

0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17

Hexadecimal values have a historical significance, 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 hexadecimal digit corresponds to four binary digits. Two hex digits map to a byte and four to a word. This is particularly useful and is evidenced by hexadecimal values being used to generate Unicode escape sequences.

There are several hexadecimal values that are useful. These are summarized in the following table:

0x0All bits clear
0x20The single bit to toggle between upper and lower case letters
0x7FA seven bit character mask
0x8000The sign bit of a 16 bit integer value
0x80000000The sign bit of a 32 bit integer value
0xDFA mask that excludes the upper/lower case bit
0xFFAll bits set in a byte
0xFFFFAll bits set in a 16 bit word
0xFFFFFFFFAll bits set in a 32 bit word

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


O'Reilly JavaScript Definitive Guide - page - 35