Base 36
Encyclopedia
Base 36 is a positional numeral system
Positional notation
Positional notation or place-value notation is a method of representing or encoding numbers. Positional notation is distinguished from other notations for its use of the same symbol for the different orders of magnitude...

 using 36
36 (number)
36 is the natural number following 35 and preceding 37.- In mathematics :36 is both the square of 6 and a triangular number, making it a square triangular number...

 as the radix
Radix
In mathematical numeral systems, the base or radix for the simplest case is the number of unique digits, including zero, that a positional numeral system uses to represent numbers. For example, for the decimal system the radix is ten, because it uses the ten digits from 0 through 9.In any numeral...

. The choice of 36 is convenient in that the digits can be represented using the Arabic numerals 0-9 and the Latin letters
Latin alphabet
The Latin alphabet, also called the Roman alphabet, is the most recognized alphabet used in the world today. It evolved from a western variety of the Greek alphabet called the Cumaean alphabet, which was adopted and modified by the Etruscans who ruled early Rome...

 A-Z (the Basic Latin alphabet). Base 36 is therefore the most compact case-insensitive alphanumeric
Alphanumeric
Alphanumeric is a combination of alphabetic and numeric characters, and is used to describe the collection of Latin letters and Arabic digits or a text constructed from this collection. There are either 36 or 62 alphanumeric characters. The alphanumeric character set consists of the numbers 0 to...

 numeral system
Numeral system
A numeral system is a writing system for expressing numbers, that is a mathematical notation for representing numbers of a given set, using graphemes or symbols in a consistent manner....

 using ASCII
ASCII
The American Standard Code for Information Interchange is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text...

 characters, although its radix economy
Radix economy
Various proposals have been made to quantify the relative costs between using different radices in representing numbers, especially in computer systems.-Definition:...

 is poor.

From a mathematical viewpoint, 36, as with all highly composite number
Highly composite number
A highly composite number is a positive integer with more divisors than any positive integer smaller than itself.The initial or smallest twenty-one highly composite numbers are listed in the table at right....

s, 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
Senary
In mathematics, a senary numeral system is a base- numeral system.Senary may be considered useful in the study of prime numbers since all primes other than 2 and 3, when expressed in base-six, have 1 or 5 as the final digit...

 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.

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 36
1 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 Decimal
1 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 36
1/2 0.5 0.I
1/3 0. 0.C
1/4 0.25 0.9
1/5 0.2 0.
1/6 0.1 0.6
1/7 0. 0.
1/8 0.125 0.4I
1/9 0. 0.4
1/10 0.1 0.3



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
GNU Multi-Precision Library
The GNU Multiple Precision Arithmetic Library, also known as GMP, is a free library for arbitrary-precision arithmetic, operating on signed integers, rational numbers, and floating point numbers...

 arbitrary-precision math library. For floating-point numbers the corresponding functions are called mpf_set_str and mpf_get_str.

Java implementation


public class Base36 {
public long decode(final String value) {
return Long.parseLong(value, 36);
}

public String encode(final long value) {
return Long.toString(value, 36);
}
}

PHP implementation


The decimal value of 12abcxyz is


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.

Python implementation


def 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')

Ruby implementation


1412823931503067241.to_s(36) #=> "aqf8aa0006eh"

Uses in practice
  • The Remote Imaging Protocol
    Remote imaging protocol
    The Remote Imaging Protocol Scripting Language, more commonly known as the Remote Imaging Protocol or RIPscrip, is a scripting language created by Jeff Reeder, Jim Bergman, and Mark Hayton to enhance bulletin board systems and other applications.RIPscrip was introduced in 1993 and consisted of...

     for bulletin board system
    Bulletin board system
    A Bulletin Board System, or BBS, is a computer system running software that allows users to connect and log in to the system using a terminal program. Once logged in, a user can perform functions such as uploading and downloading software and data, reading news and bulletins, and exchanging...

    s used base 36 notation for transmitting coordinates in a compact form.
  • The Siebel
    Siebel Systems
    Siebel CRM Systems, Inc. was a software company principally engaged in the design, development, marketing, and support of customer relationship management applications. The company was founded by Thomas Siebel in 1993. At first known mainly for its sales force automation products, the company...

     CRM
    Customer relationship management
    Customer relationship management is a widely implemented strategy for managing a company’s interactions with customers, clients and sales prospects. It involves using technology to organize, automate, and synchronize business processes—principally sales activities, but also those for marketing,...

     application uses base 36 as the unique identifier generator for all the entities in its model (e.g., 1-8GH4DX).
  • Many URL redirection
    URL redirection
    URL redirection, also called URL forwarding and the very similar technique domain redirection also called domain forwarding, are techniques on the World Wide Web for making a web page available under many URLs.- Similar domain names :...

     systems like TinyURL
    TinyURL
    TinyURL is a URL shortening service, a web service that provides short aliases for redirection of long URLs. Kevin Gilbertson, a web developer, launched the service in January 2002 so that he would be able to link directly to newsgroup postings that frequently had long and cumbersome addresses.-...

     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
    Gregorian calendar
    The Gregorian calendar, also known as the Western calendar, or Christian calendar, is the internationally accepted civil calendar. It was introduced by Pope Gregory XIII, after whom the calendar was named, by a decree signed on 24 February 1582, a papal bull known by its opening words Inter...

     dates in file names, using one digit each for the day and the month.
  • Dell
    Dell
    Dell, Inc. is an American multinational information technology corporation based in 1 Dell Way, Round Rock, Texas, United States, that develops, sells and supports computers and related products and services. Bearing the name of its founder, Michael Dell, the company is one of the largest...

     uses a 5 or 7 digit base 36 number (Service Tag) as a compact version of their Express Service Codes.
  • The software package SalesLogix
    Sage Group
    The Sage Group plc , commonly known as Sage, is a global enterprise software company headquartered in Newcastle upon Tyne, United Kingdom. It is the world's third-largest supplier of enterprise resource planning software , the largest supplier to small businesses, and has 6.1 million customers...

     uses base 36 as part of its database identifiers.
  • The TreasuryDirect
    TreasuryDirect
    TreasuryDirect is a website run by the United States Treasury that allows US individual investors to purchase Treasury securities such as T-Bills and others directly from the U.S. government...

     website, which allows individuals to buy and redeem securities directly from the U.S. Department of the Treasury in paperless electronic form, serializes security purchases in an account using a 4 digit base 36 number. However, the Latin letters A-Z are used before the Arabic numerals 0-9, so that the purchases are listed as AAAA, AAAB... AAAZ, AAA0, AAA1... AAA9, AABA...
  • The E-mail client
    E-mail client
    An email client, email reader, or more formally mail user agent , is a computer program used to manage a user's email.The term can refer to any system capable of accessing the user's email mailbox, regardless of it being a mail user agent, a relaying server, or a human typing on a terminal...

     program PMMail encodes the UNIX time
    Unix time
    Unix time, or POSIX time, is a system for describing instants in time, defined as the number of seconds elapsed since midnight Coordinated Universal Time of Thursday, January 1, 1970 , not counting leap seconds, which are declared by the International Earth Rotation and Reference Systems Service...

     of the email's arrival and uses this for the first six characters of the message's filename.
  • MediaWiki stores uploaded files in directories with names derived from the base-36 representation of a uploaded file's checksum .
  • Siteswap
    Siteswap
    Siteswap is a notation used to describe juggling patterns. It encodes the number of beats of each throw, which is related to their height, and the hand to which the throw is to be made...

    , a type of juggling notation, frequently employs 0-9 and a-z to signify the dwell time of a toss (which may roughly be thought of as the height of the throw). Throws higher than 'z' may be made but no notation has widespread acceptance for these throws.
  • Minecraft
    Minecraft
    Minecraft is a sandbox-building independent video game written in Java originally by Swedish creator Markus "Notch" Persson and now by his company, Mojang, formed from the proceeds of the game. It was released as an alpha on May 17, 2009, with a beta version on December 20, 2010...

     stores level chunk files in directories with names derived from the base-36 representation of a chunk's position.
  • In SEDOL
    SEDOL
    SEDOL stands for Stock Exchange Daily Official List, a list of security identifiers used in the United Kingdom and Ireland for clearing purposes. The numbers are assigned by the London Stock Exchange, on request by the security issuer...

     securities identifiers, the check digit is computed from a weighted sum of the first six characters, each character interpreted in base-36.
  • In the International Securities Identification Number (ISIN), the check digit is computed by first taking the value of each character in base-36, concatenating the numbers together, then doing a weighted sum.

External links
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK