Base36

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[1] (the lowercase ISO basic Latin alphabet).

Each Base36 digit contains log2(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 "1Y2P0IJ32E8E7" in base-36. Similarly, the 32-bit signed integer maximum value of "2147483647" is "ZIK0ZJ" in base-36.

Standard implementations

The C standard library since C89 supports base36 numbers via the strtol and strtoul functions[2]

In the Common Lisp standard (ANSI INCITS 226-1994), functions like parse-integer support a radix of 2 to 36.[3]

Java SE supports conversion from/to String to different bases from 2 up to 36. For example, [1] and [2]

Just like Java, JavaScript also supports conversion from/to String to different bases from 2 up to 36. [3]

PHP, like Java, supports conversion from/to String to different bases from 2 up to 36 using the base_convert function, available since PHP 4.

Go supports conversion to string to different bases from 2 up to 36 using the built-in strconv.FormatInt(), and strconv.FormatUint() functions,[4][5] and conversions from string encoded in different bases from 2 up to 36 using the built-in strconv.ParseInt(), and strconv.ParseUint() functions.[6][7]

Python allows conversions of strings from base 2 to base 36.[8]

Raku supports base2 to base36 for all its real numeric types with its builtins: base[9] and parse-base.[10]

See also

References

  1. ^ "ECMAScript® 2026 Language Specification".
  2. ^ "strtol, strtoll — cppreference.com".
  3. ^ "Common Lisp HyperSpec". LispWorks. Retrieved 3 August 2022.
  4. ^ "Strconv package - strconv - PKG.go.dev".
  5. ^ "Strconv package - strconv - PKG.go.dev".
  6. ^ "Strconv package - strconv - PKG.go.dev".
  7. ^ "Strconv package - strconv - PKG.go.dev".
  8. ^ "Built-in Functions — Python 3.10.0 documentation".
  9. ^ "base".
  10. ^ "routine parse-base".

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.