Open jbenet opened 10 years ago
The need to maintain a table of alphabets may be a reason to use different prefixing entirely. In a sense, 0b
and 0x
aren't base encodings, but alphabet encodings. The ambiguity when dealing with multiple alphabets (e.g. as in base64 and base58) suggests that since we are standardizing alphabets anyway, we might as well give them prefix identifiers.
Erlang does this already, up to base 36: 2#100 == 4 10#100 == 100 36#100 == 1296
3.2 Number
There are two types of numeric literals, integers and floats. Besides the conventional notation, there are two Erlang-specific notations:
$char ASCII value or unicode code-point of the character char.
base#value Integer with the base base, which must be an integer in the range 2..36. In Erlang 5.2/OTP R9B and earlier versions, the allowed range is 2..16.
Oh cool! :+1:
hmm the problem with #
is it wont work in alphanumeric fields (which are more common than fields with numbers and symbols).
When ascii encoding numbers of different bases, we either (a) signal elsewhere what the base is (non self describing and to be avoided), or (b) prefix the characters with a base identifier:
But what about other bases? base32, base64, base58 are all popular. What about this encoding: