Flattened Grid Index Decoder
Decode a zero-based row-major flattened grid index with explicit dimensions.
Description
Decode a zero-based row-major flattened grid index with explicit dimensions.
A row-major linear index can be decoded by dividing by the number of columns. The quotient identifies the row and the remainder identifies the column.
When to use this tool
Decode a zero-based row-major flattened grid index with explicit dimensions.
- Prepare the supplied index, rows, columns fields for this operation.
- Compare the complete example with the representation used by your own input before carrying the result into another step.
How to use the tool and how it works
- Enter index, rows, columns. Use the exact text syntax, units and index conventions explained below.
- Run the tool. If input validation fails, correct the supplied fields before interpreting any result.
- Read result.row, result.column. Interpret false, null and empty lists using the distinctions below; they can be valid outputs.
Validate rows/columns and index within rows*columns. Return floor(index/columns) and index modulo columns.1
| Input field | Meaning and representation | Accepted input |
|---|---|---|
| index | index. | Integer from 0 to rows * columns - 1 inclusive |
| rows | rows. | Integer from 1 to 1e6 inclusive |
| columns | columns. | Integer from 1 to 1e6 inclusive |
| Output field | Interpretation |
|---|---|
| result | Object containing the named outputs below. |
| result.row | The row value under the stated formula or text convention. |
| result.column | The column value under the stated formula or text convention. |
{
"input": {
"index": 5,
"rows": 2,
"columns": 3
},
"output": {
"result": {
"row": 1,
"column": 2
}
}
} Limitations and assumptions
- Coordinates are zero-based and no grid data is inspected. The calculation assumes dense row-major storage without padding, tiling or a physical byte stride.
- Every declared top-level field is required and unexpected fields are rejected. Numeric inputs must be finite; ordinary text fields are bounded to 8,192 UTF-16 code units, with tighter operation-specific limits where stated.
- Ordinary string lists have at most 128 entries of at most 128 code units each; numeric lists and matrices have separate bounded size checks. Nonfinite results and excessively large serialized outputs are rejected.
- Indexes are zero-based and spans have an exclusive end unless explicitly stated otherwise. A valid false, null or empty-list result is distinct from malformed input.
Alternative or Complementary methods
Use explicit source-index maps when rearranging data or planning missing-value fills. Keep row-major coordinates, cyclic indexes and one-based occurrence numbers distinct, and inspect null donor positions before copying values.
References
Similar or alternative tools
- Grid Coordinate Linear Index
Encode zero-based rectangular grid coordinates to a row-major list index.
- Adjacent Change Indexes
Return indexes whose value differs from the previous supplied string, not CSS change hints or a value transform.