DiemazzHD RadioBonne Nuit Ma Ch Battle of Salamanca KHDC Career Education Corporation San Silvestro al Quirinale Christianity in Iran Status of religious freedom in Pakistan wylk Emily, Minnesota Brugada syndrome British Leeward Islands A4133 road (Great Britain) t991t Zhao Jiuzhang Visigoths cebu jobs Jubilo pga golf Chaville Revenue List of years in music Giant Wild Goose Pagoda co pilot gps Walter Scott Ankh Sodhi Checked baggage Shinar celebrity crust Langrial Pilin Ɍ Image:Oncidium splendidum0 jpg Steve Thompson (musician) Algol 60 WWGL Church body Folsom, Pennsylvania Template:Anhui Zhoushan Refracting telescope clarks sago EVDO BoyTown Deal or No Deal (Netherlands) |
Base 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] Base 36 is therefore the most compact case-insensitive alphanumeric numeral system using ASCII characters, although its radix economy is poor. (Compare with base 16 and base 64.) From a mathematical viewpoint, 36 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.
ExamplesConversion table:
Some numbers in decimal and base 36:
Conversion32- 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. Python Conversion Codedef base36decode(input): CLIST="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rv = pos = 0 charlist = list(input) charlist.reverse() for char in charlist: rv += CLIST.find(char) * 36**pos pos += 1 return rv def base36encode(input): CLIST="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rv = "" while input != 0: rv = CLIST[input % 36] + rv input /= 36 return rv print base36decode("AQF8AA0006EH") print base36encode(1412823931503067241) C# Conversion Classusing System; namespace calculate_base_36 { public class base36 { private static char[] b36cd; /// <summary> /// initilises the characters in base 36 /// </summary> protected static void initbase36() { b36cd = new char[] {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; } /// <summary> /// Encodes an int into a base 36 string /// if you were to alter the values in the b36cd then /// this could be to any base value. /// </summary> /// <param name="value">(int) the input decimal value</param> /// <returns>(string) the output string base 36 converter</returns> public static string encodeb36(Int64 value) { initbase36(); // set the char[] array string rv = ""; // starting value while (value != 0) { rv = b36cd[value % b36cd.Length] + rv; value /= b36cd.Length; } rv = rv.ToUpper(); return rv; } /// <summary> /// This decodes the base 36 number into a decimal number /// though this could be used to decode any base number depending on the input /// on the char[] b36cd /// </summary> /// <param name="input"></param> /// <returns>(int) the decimal value of the base 36 number</returns> public static Int64 base36decode(string input) { initbase36(); input = input.Trim(); input = input.ToLower(); Int64 rv = 0; // break string into characters char[] encchars = input.ToCharArray(); // reverse the array Array.Reverse(encchars); // loop through the values for (int i = 0; i < encchars.Length; i++) { // find the index in the array that the char resides int valueindex = Array.IndexOf(b36cd, encchars[i]); // the actual value given by that is // the index multiplied by the base number to the power of the index double temp = valueindex * Math.Pow(b36cd.Length, i); // add this value to the counter until there are no more values rv += Convert.ToInt64(temp); } // return the total result return rv; } } } Uses in practice
References
External links
|
Site Map: RSS 2.0
Recent Searches:
Base 36
Related Pages: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||