{{short description |Encoding for a sequence of byte values using 36 printable characters}} {{Refimprove |date=November 2008}} {{About |an encoding scheme used to represent binary data as text |the positional numeral system using the radix 36|Base 36}}
'''Base36''' is a binary-to-text encoding that represents binary data in an ASCII string format by translating it into a radix-36 representation. The choice of 36 is convenient in that the digits can be represented using the numerals 0–9 and the letters a-z<ref>{{Cite web|url=https://tc39.es/ecma262/multipage/ecmascript-data-types-and-values.html#sec-numeric-types-number-tostring|title = ECMAScript® 2026 Language Specification}}</ref> (the lowercase ISO basic Latin alphabet).
Each Base36 digit contains {{nowrap|log<sub>2</sub>(36) ≈ 5.17 bits}} of information, so six bits is sufficient to represent each digit. Base36 numbers can also be expanded to pairs of senary (base 6) digits.
== Conversion ==
Signed 32- and 64-bit integers will only hold at most 6 or 13 base-36 digits, respectively (that many base-36 digits can overflow the 32- and 64-bit integers). For example, the 64-bit signed integer maximum value of "9223372036854775807" is "{{mono|1Y2P0IJ32E8E7}}" in base-36. Similarly, the 32-bit signed integer maximum value of "2147483647" is "{{mono|ZIK0ZJ}}" in base-36.
=== Standard implementations === The C standard library since C89 supports base36 numbers via the strtol and strtoul functions<ref>{{Cite web|url=https://en.cppreference.com/w/c/string/byte/strtol|title = strtol, strtoll — cppreference.com}}</ref>
In the Common Lisp standard (ANSI INCITS 226-1994), functions like <code>parse-integer</code> support a radix of 2 to 36.<ref name="HyperSpec-Radix">{{cite web|url=http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_r.htm#radix|title=Common Lisp HyperSpec|website=LispWorks|access-date=3 August 2022}}</ref>
Java SE supports conversion from/to String to different bases from 2 up to 36. For example, [https://docs.oracle.com/javase/8/docs/api/java/lang/Character.html#digit-char-int-] and [https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html#BigInteger-java.lang.String-int-]
Just like Java, JavaScript also supports conversion from/to String to different bases from 2 up to 36. [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toString]
PHP, like Java, supports conversion from/to String to different bases from 2 up to 36 using the [https://secure.php.net/manual/en/function.base-convert.php base_convert] function, available since PHP 4.
Go supports conversion to string to different bases from 2 up to 36 using the built-in <code>strconv.FormatInt()</code>, and <code>strconv.FormatUint()</code> functions,<ref>{{Cite web|url=https://golang.org/pkg/strconv/#FormatInt|title = Strconv package - strconv - PKG.go.dev}}</ref><ref>{{Cite web|url=https://golang.org/pkg/strconv/#FormatUint|title=Strconv package - strconv - PKG.go.dev}}</ref> and conversions from string encoded in different bases from 2 up to 36 using the built-in <code>strconv.ParseInt()</code>, and <code>strconv.ParseUint()</code> functions.<ref>{{Cite web|url=https://golang.org/pkg/strconv/#ParseInt|title = Strconv package - strconv - PKG.go.dev}}</ref><ref>{{Cite web|url=https://golang.org/pkg/strconv/#ParseUint|title = Strconv package - strconv - PKG.go.dev}}</ref>
Python allows conversions of strings from base 2 to base 36.<ref>{{Cite web|url=https://docs.python.org/3/library/functions.html#int|title = Built-in Functions — Python 3.10.0 documentation}}</ref>
Raku supports base2 to base36 for all its real numeric types with its builtins: <code>base</code><ref>{{Cite web|url=https://docs.raku.org/routine/base|title = base}}</ref> and <code>parse-base</code>.<ref>{{Cite web|url=https://docs.raku.org/type/Str#routine_parse-base|title = routine parse-base}}</ref>
==See also== * {{Annotated link|Senary}} * Uuencoding
==References== {{Reflist}}
== External links == * [https://web.archive.org/web/20220705000329/http://www.wordwizard.com/phpbb3/viewtopic.php?f=16&t=17971 A discussion about the proper name for base 36] at the Wordwizard Clubhouse * [http://primes.utm.edu/notes/words.html The Prime Lexicon], a list of words that are prime numbers in base 36 * [http://www.tonymarston.net/php-mysql/converter.html A Binary-Octal-Decimal-Hexadecimal-Base36 converter] written in PHP * [http://www.stum.de/2008/10/20/base36-encoderdecoder-in-c A C# base 36 encoder and decoder] * [https://web.archive.org/web/20190817084532/https://www.wikiofcode.com/The_HexaTriDecimal_Numbering_System sample in C# that demonstrates the HexaTriDecimal Numbering System including string parsing, as well as increment/decrement operations]
Category:Binary-to-text encoding formats Category:Computer arithmetic Category:Data serialization formats Category:Positional numeral systems
{{Data Exchange}}