Re: Spreadsheet column labels as base-26 numbers

On Tue, 25 Apr 2023 at 21:29, Michael Kay <mike@saxonica.com> wrote:

> It was suggested during the meeting that spreadsheet column labels can be
> interpreted as base-26 numbers.
>
> I can't immediately see how this is supposed to work.
>
> The typical sequence is A, B, C, ... Z, AA, AB, AC, ...
>
> What is the zero-digit here? It can't be A, because then A would be 0 and
> AA would also be 0.
>

In spreadsheets (Excel, LibreOffice Calc, etc.) the first cell A1 is the
coordinates (1, 1). -- That is, there is no 0 digit.


> If A=1, with radix=27, then Z=26 and AA=28 so there is a gap in the
> sequence.
>
> While the sequence is logical and practical, I can't see any way to
> interpret the column label as a base-N number.
>

In https://www.w3.org/TR/css-counter-styles-3/, that defines several
algorithms for formatting numbers. These include:

1. Alphabetic (https://www.w3.org/TR/css-counter-styles-3/#alphabetic-system)
e.g. upper-alpha -- These don't have a defined symbol for "0". The
algorithm performs a `value = value - 1` at each step in the loop.

2. Numeric (https://www.w3.org/TR/css-counter-styles-3/#numeric-system)
e.g. decimal -- These have a defined symbol for "0". The algorithm works
like the alphabetic algorithm, but has a special case when the value is
"0", and does not subtract 1 from value at each step.

3. Additive (https://www.w3.org/TR/css-counter-styles-3/#additive-system)
e.g. armenian, lower-roman -- These are specified as a map of (symbol,
value) pairs. Note that in the roman numerals case, it defines symbols for
the subtractive case (e.g. `map { 5: "v", 4: "iv", 1: "i" }`).

There are several other systems, but I don't think those are relevant to
parsing number formats. The specification defines a range of number formats
from different languages (see
https://www.w3.org/TR/css-counter-styles-3/#simple-numeric and
https://www.w3.org/TR/css-counter-styles-3/#complex-predefined-counters).

Kind regards,
Reece


> Michael Kay
> Saxonica
>
>
>
>
>
>
>

Received on Tuesday, 25 April 2023 21:31:26 UTC