Bijective Base 26
Using bijective numeration, it is possible to operate in base 26 without a zero; it uses digits "A" to "Z" to represent one to twenty-six and has no zero. Many spreadsheets including Microsoft Excel use the 26-adic counting system with the "digits" A-Z to label the columns of a spreadsheet, starting A, B, C... Z, AA, AB... AZ, BA... ZZ, AAA, etc. A variant of this system is used to name variable stars.
The following algorithm (in Java) will allow you to convert a 0 based number string to a Bijective Base 26 number. This means that 0 = A, 26 = AA, 676 = AAA and so forth.
public static String toBase26(int value) { // Note: This is a slightly modified version of the Alphabet-only conversion algorithm value = Math.abs(value); String converted = ""; boolean iteration = false; // Repeatedly divide the number by 26 and convert the // remainder into the appropriate letter. do { int remainder = value % 26; // Compensate for the last letter of the series being corrected on 2 or more iterations. if (iteration && value < 25) { remainder--; } converted = (char)(remainder + 'A') + converted; value = (value - remainder) / 26; iteration = true; } while (value > 0); return converted; }Read more about this topic: Hexavigesimal
Famous quotes containing the word base:
“Music is of two kinds: one petty, poor, second-rate, never varying, its base the hundred or so phrasings which all musicians understand, a babbling which is more or less pleasant, the life that most composers live.”
—HonorĂ© De Balzac (17991850)