Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Numeral system
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Generalized variable-length integers== {{main|Punycode}} More general is using a [[mixed radix]] notation (here written [[Endianness|little-endian]]) like <math>a_0 a_1 a_2</math> for <math>a_0 + a_1 b_1 + a_2 b_1 b_2</math>, etc. This is used in [[Punycode]], one aspect of which is the representation of a sequence of non-negative integers of arbitrary size in the form of a sequence without delimiters, of "digits" from a collection of 36: aβz and 0β9, representing 0β25 and 26β35 respectively. There are also so-called threshold values (<math>t_0, t_1, \ldots</math>) which are fixed for every position in the number. A digit <math>a_i</math> (in a given position in the number) that is lower than its corresponding threshold value <math>t_i</math> means that it is the most-significant digit, hence in the string this is the end of the number, and the next symbol (if present) is the least-significant digit of the next number. For example, if the threshold value for the first digit is ''b'' (i.e. 1) then ''a'' (i.e. 0) marks the end of the number (it has just one digit), so in numbers of more than one digit, first-digit range is only bβ9 (i.e. 1β35), therefore the weight ''b''<sub>1</sub> is 35 instead of 36. More generally, if ''t<sub>n</sub>'' is the threshold for the ''n''-th digit, it is easy to show that <math>b_{n+1}=36-t_n</math>. Suppose the threshold values for the second and third digits are ''c'' (i.e. 2), then the second-digit range is aβb (i.e. 0β1) with the second digit being most significant, while the range is cβ9 (i.e. 2β35) in the presence of a third digit. Generally, for any ''n'', the weight of the (''n'' + 1)-th digit is the weight of the previous one times (36 β threshold of the ''n''-th digit). So the weight of the second symbol is <math>36 - t_0 = 35</math>. And the weight of the third symbol is <math>35(36 - t_1) = 35\cdot34 = 1190</math>. So we have the following sequence of the numbers with at most 3 digits: ''a'' (0), ''ba'' (1), ''ca'' (2), ..., 9''a'' (35), ''bb'' (36), ''cb'' (37), ..., 9''b'' (70), ''bca'' (71), ..., 99''a'' (1260), ''bcb'' (1261), ..., 99''b'' (2450). Unlike a regular ''n''-based numeral system, there are numbers like 9''b'' where 9 and ''b'' each represent 35; yet the representation is unique because ''ac'' and ''aca'' are not allowed β the first ''a'' would terminate each of these numbers. The flexibility in choosing threshold values allows optimization for number of digits depending on the frequency of occurrence of numbers of various sizes. The case with all threshold values equal to 1 corresponds to [[bijective numeration]], where the zeros correspond to separators of numbers with digits which are non-zero.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)