Ranks are the eight horizontal lines or rows of a Chessboard, labeled from '1' to '8'. Each rank contains eight horizontally arranged Squares of alternating white and black, or light and dark Color. The First Rank is White's back rank, while the Eights Rank is Black's back rank.

Square Mapping Notes

Whether the square difference of neighbored squares on a rank or file is either 1 or 8, depends on the square mapping. We further rely on little-endian rank-file mapping, which keeps consecutive squares of a rank as neighbored elements in Memory (or register).

Square Difference

Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares on a Rank is one.

Enumeration

As mentioned, on a Chessboard the eight ranks are labeled from '1' to '8'. To make them zero based indices as appropriate for C-like programming languages, we enumerate ranks from 0 to 7. Little-endian rank-mapping (as used here) assigns the first Rank to index zero. Three bits are required to enumerate from 0 to 7.

A little-endian rank-mapping enumeration in C++ might look like this:

## Table of Contents

Home * Chess * RanksRanksare the eight horizontal lines or rows of a Chessboard, labeled from '1' to '8'. Each rank contains eight horizontally arranged Squares of alternating white and black, or light and dark Color. The First Rank is White's back rank, while the Eights Rank is Black's back rank.## Square Mapping Notes

Whether the square difference of neighbored squares on a rank or file is either 1 or 8, depends on the square mapping. We further rely on little-endian rank-file mapping, which keeps consecutive squares of a rank as neighbored elements in Memory (or register).## Square Difference

Within a 0..63 square index range and the mentioned square mapping (a1 = 0), the difference of two neighbored squares on a Rank isone.## Enumeration

As mentioned, on a Chessboard the eight ranks are labeled from '1' to '8'. To make them zero based indices as appropriate for C-like programming languages, we enumerate ranks from 0 to 7. Little-endian rank-mapping (as used here) assigns the first Rank to index zero. Three bits are required to enumerate from 0 to 7.A little-endian rank-mapping enumeration in C++ might look like this:

## Rank from Square

Rank-File mapping of squares keeps the rank index as the three upper bits of a six bit Square index.## Rank-Distance

The rank-distance is the absolute difference between two ranks (their 0-7 indices). The maximum rank-distance is 7.## See also

## What links here?

Up one Level