# H3 Index Representations
## Introduction
The **H3** system assigns a unique hierarchical index to each cell. The **H3** index of a resolution *r* cell begins with the appropriate resolution 0 base cell number. This is followed by a sequence of *r* digits 0-6, where each *i*th digit *d*i specifies one of the 7 cells centered on the cell indicated by the coarser resolution digits *d*1 through *d*i-1. A local hexagon coordinate system is assigned to each of the resolution 0 base cells and is used to orient all hierarchical indexing child cells of that base cell. The assignment of digits 0-6 at each resolution uses a *Central Place Indexing* arrangement (see [Sahr, 2014](http://webpages.sou.edu/~sahrk/sqspc/pubs/autocarto14.pdf)). In the case of the 12 pentagonal cells the indexing hierarchy produced by sub-digit 1 is removed at all resolutions.
Child hexagons are linearly smaller than their parent hexagons.
## H3Index Representation
The **H3Index** is the integer representation of an **H3** index, which can be placed into multiple modes to indicate the concept being indexed.
* Mode 1 is an **H3** Cell (Hexagon/Pentagon) index.
* Mode 2 is an **H3** Unidirectional Edge (Cell A -> Cell B) index.
* Mode 3 is planned to be a bidirectional edge (Cell A <-> Cell B).
* Mode 0 is reserved and indicates an invalid **H3** index.
* This mode remains, partially, for backwards compatibility with an older version of H3.
Mode 0 contains a special index, `H3_NULL`, which is unique: it is bit-equivalent to `0`.
This index indicates, *specifically*, an invalid, missing, or uninitialized **H3** index;
it is analogous to `NaN` in floating point.
It should be used instead of an arbitrary Mode 0 index, due to its uniqueness and easy identifiability.
The components of the **H3** cell index (mode 1) are packed into a 64-bit integer in order, highest bit first, as follows:
* 1 bit reserved and set to 0,
* 4 bits to indicate the index mode,
* 3 bits reserved and set to 0,
* 4 bits to indicate the cell resolution 0-15,
* 7 bits to indicate the base cell 0-121, and
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total are reserved for resolutions 1-15)
The components of the **H3** unidirectional edge index (mode 2) are packed into a 64-bit integer in order, highest bit first, as follows:
* 1 bit reserved and set to 0,
* 4 bits to indicate the index mode,
* 3 bits to indicate the edge 1-6 of the cell to traverse,
* 4 bits to indicate the cell resolution 0-15,
* 7 bits to indicate the base cell 0-121, and
* 3 bits to indicate each subsequent digit 0-6 from resolution 1 up to the resolution of the cell (45 bits total are reserved for resolutions 1-15)
The canonical string representation of an **H3Index** is the hexadecimal representation of the integer, using lowercase letters. The string representation is variable length (no zero padding) and is not prefixed or suffixed.
The three bits for each unused digit are set to 7.
## Bit layout of H3Index
The layout of an **H3Index** is shown below in table form. The interpretation of the "Reserved/edge" field differs depending on the mode of the index.
|
0x0F |
0x0E |
0x0D |
0x0C |
0x0B |
0x0A |
0x09 |
0x08 |
0x07 |
0x06 |
0x05 |
0x04 |
0x03 |
0x02 |
0x01 |
0x00 |
0x30 |
Reserved |
Mode |
Reserved/edge |
Resolution |
Base cell |
0x20 |
Base cell |
Digit 1 |
Digit 2 |
Digit 3 |
Digit 4 |
Digit 5 |
0x10 |
Digit 5 |
Digit 6 |
Digit 7 |
Digit 8 |
Digit 9 |
Digit 10 |
0x00 |
Digit 10 |
Digit 11 |
Digit 12 |
Digit 13 |
Digit 14 |
Digit 15 |