# Base36

> Mediated Wiki article. Canonical URL: https://mediated.wiki/source/Base36
> Markdown URL: https://mediated.wiki/source/Base36.md
> Source: https://en.wikipedia.org/wiki/Base36
> Source revision: 1342116584
> License: Creative Commons Attribution-ShareAlike 4.0 International (https://creativecommons.org/licenses/by-sa/4.0/)

{{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](/source/binary-to-text_encoding) that represents [binary data](/source/binary_data) in an [ASCII](/source/ASCII) string format by translating it into a [radix](/source/radix)-36 representation. The choice of 36 is convenient in that the digits can be represented using the [numerals](/source/Arabic_numerals) 0–9 and the [letters](/source/Latin_alphabet) 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](/source/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](/source/senary) (base 6) digits.

== Conversion ==

Signed [32](/source/32-bit_computing)- and [64](/source/64-bit_computing)-[bit](/source/Bitwise_operation) [integers](/source/Integer) 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](/source/9223372036854775807)" is "{{mono|1Y2P0IJ32E8E7}}" in base-36.
Similarly, the 32-bit signed integer maximum value of "[2147483647](/source/2147483647)" is "{{mono|ZIK0ZJ}}" in base-36.

=== Standard implementations  ===
[The C standard library](/source/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](/source/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](/source/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](/source/Java_(programming_language)), [JavaScript](/source/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](/source/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](/source/Go_(programming_language)) 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](/source/Python_(programming_language)) 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](/source/Raku_(programming_language)) 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](/source/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 number](/source/prime_number)s in base 36
* [http://www.tonymarston.net/php-mysql/converter.html A Binary-Octal-Decimal-Hexadecimal-Base36 converter] written in [PHP](/source/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}}

---
Adapted from the Wikipedia article [Base36](https://en.wikipedia.org/wiki/Base36) by Wikipedia contributors ([contributor history](https://en.wikipedia.org/wiki/Base36?action=history)). Available under [Creative Commons Attribution-ShareAlike 4.0 International](https://creativecommons.org/licenses/by-sa/4.0/). Changes may have been made.
