From Wikipedia, the free encyclopedia

This article
needs additional citations for verification. Please help
improve this article by adding citations to
reliable sources. Unsourced material may be
challenged and
removed. (November 2008)
Numeral systems by cultureHindu-Arabic numeralsWestern Arabic (Hindu numerals)Eastern ArabicIndian familyTamilBurmeseKhmerLaoMongolianThaiEast Asian numeralsChineseJapaneseSuzhouKoreanVietnameseCounting rodsAlphabetic numeralsAbjadArmenianĀryabhaṭaCyrillicGe'ezGreekGeorgianHebrewOther systemsAegeanAtticBabylonianBrahmiEgyptianEtruscanInuitKharosthiMayanQuipuRomanSumerianUrnfieldList of numeral system topicsPositional systems by baseDecimal (10)
2,
3,
4,
5,
6,
7,
8,
9,
11,
12,
13,
14,
15,
16,
20,
24,
30,
36,
60,
64Balanced ternaryNon-positional systemUnary numeral system (Base 1)
List of numeral systemsv d eBase 36 is a
positional numeral system using
36 as the
radix. The choice of 36 is convenient in that the digits can be represented using the
Arabic numerals 0-9 and the
Latin letters A-Z
[1] (the
ISO basic Latin alphabet). Base 36 is therefore the most compact
case-insensitive alphanumeric numeral system using
ASCII characters, although its
radix economy is poor.
From a
mathematical viewpoint, 36, as with all
highly composite numbers, is a convenient choice for a base in that it is divisible by both 2 and 3, and by their multiples 4, 6, 9, 12 and 18. Each base 36 digit can be represented as two
base 6 digits.
The most common
latinate name for base 36 seems to be
hexatridecimal, although
sexatrigesimal would arguably be more correct. The intermediate form
hexatrigesimal is also sometimes used. For more background on this naming confusion, see the entry for
hexadecimal. Another name occasionally seen for base 36 is
alphadecimal, a
neologism coined based on the fact that the system uses the
decimal digits and the letters of the Latin alphabet.
Contents1 Examples2 Conversion2.1 Java implementation2.2 PHP implementation2.3 Python implementation2.4 Ruby implementation3 Uses in practice4 References5 External links[
edit]Examples
Conversion table:
Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
Base 36 0 1 2 3 4 5 6 7 8 9 A B C D E F G H
Decimal 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Base 36 I J K L M N O P Q R S T U V W X Y Z
Some numbers in decimal and base 36:
Decimal Base 361 1
10 A
100 2S
1,000 RS
10,000 7PS
100,000 255S
1,000,000 LFLS
1,000,000,000 GJDGXS
1,000,000,000,000 CRE66I9S
Base 36 Decimal1 1
10 36
100 1,296
1000 46,656
10000 1,679,616
100000 60,466,176
1000000 2,176,782,336
10000000 78,364,164,096
100000000 2,821,109,907,456
Fraction Decimal Base 361/2 0.5 0.I
1/3 0.3 0.C
1/4 0.25 0.9
1/5 0.2 0.7
1/6 0.16 0.6
1/7 0.142857 0.5
1/8 0.125 0.4I
1/9 0.1 0.4
1/10 0.1 0.3L
[
edit]Conversion
32- and 64-bit integers will only hold up to 6 or 12 base-36 digits, respectively. For numbers with more digits, one can use the functions
mpz_set_str and mpz_get_str in the
GMP arbitrary-precision math library. For floating-point numbers the corresponding functions are called
mpf_set_str and mpf_get_str.
[
edit]
Java implementationpublic class Base36 {
public long decode(
final String value) {
return Long.parseLong(value, 36);
}
public String encode(
final long value) {
return Long.toString(value, 36);
}
}
[
edit]
PHP implementationThe decimal value of 12abcxyz is
<?php print base_convert("12abcxyz",36,10);
?>The base_convert function converts the value to a floating-point number, which loses accuracy for numbers above implementation-specific limits. For php 5.3.6 on 64-bit linux, the highest base-36 integer that can be represented accurately is 1y2p0ij32e8e7, equal to 2^63-1 or 9223372036854775807. Negative signs, decimal points and any characters outside the range 0-z are stripped prior to conversion, so -1.5 = 15 = f, rather than -1.i as might be expected.
[
edit]
Python implementationdef base36encode(number, alphabet='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
"""Convert positive integer to a base36 string."""
if not isinstance(number, (int, long)):
raise TypeError('number must be an integer')
# Special case for zero
if number == 0:
return alphabet[0]
base36
= ''
sign
= ''
if number < 0:
sign
= '-'
number = - number
while number != 0:
number
, i = divmod(number, len(alphabet))
base36 = alphabet[i] + base36
return sign + base36
def base36decode(number):
return int(number, 36)
print base36encode(1412823931503067241)
print base36decode('AQF8AA0006EH')
[
edit]
Ruby implementation1412823931503067241.to_s
(36
) #=> "aqf8aa0006eh"
[
edit]Uses in practice
The
Remote Imaging Protocol for
bulletin board systems used base 36 notation for transmitting coordinates in a compact form.
The
Siebel CRM application uses base 36 as the unique identifier generator for all the entities in its model (e.g., 1-8GH4DX).
Many
URL redirection systems like
TinyURL or
SnipURL/
Snipr also use base 36 integers as compact alphanumeric identifiers.
Various systems such as
RickDate use base 36 as a compact representation of
Gregorian dates in file names, using one digit each for the day and the month.
Dell uses a 5 or 7 digit base 36 number (Service Tag) as a compact version of their Express Service Codes.
The software package
SalesLogix uses base 36 as part of its database identifiers.
[2