Thoughts on Intercommunication: Integers

I like to spend my time imagining like what a proper computer network would look.  That overwhelming
concern is the representation of data at the lowest level, the level of individual numerical digits.

The first issue is the unnecessary grouping of digits into arbitrary units.  A proper binary network
will use bit counts and not octet counts, and similarly for any other network with a different base.

Not all types of data need special representations in such networks; in considering how to represent
the trie and hash table, I noticed the most reasonable answer was to represent them with a more base
type, the ordered set, using two to establish a mapping; this gives two different types an identical
representation, which I accept as proof that they're not primitive enough for special consideration.

The integer, however, is extremely important and, when dealing solely in bits, its representation is
at first unclear.  Integers of a fixed length are uninteresting here.  That most pure representation
for integers of any length is a bit indicating whether the next bit is the final bit of the integer,
or if the integer continues.  This doubles the integer's size in bits, compared to that fixed length
representation, and the simple optimization of grouping the bits to lessen this cost is ineffective.

A simple optimization presents itself: An integer of any length can be represented by a pure integer
communicating the length in bits of the true integer that follows.  This scheme breaks even with six
bits, is smaller with seven bit integers, and breaks even again with octets, before staying smaller.
Any six bit integer would need twelve bits for the most pure representation, and six bits are needed
to store six for the other representation; what follows are these bit representations of fifty-five:

11 11 10 11 11 01
11 11 00 11 01 11

I originally figured a representation with a trailing zero bit, that's to mean not using that ending
bit of that most pure representation to store a bit of the integer, be best; however, it makes for a
longer bit chain and makes one wonder what the integer representation consisting of a lone bit ought
to represent, both of which are addressed cleanly by avoiding the question and doing away with that,
although the question of what a length of zero, expressed with two zeroes, should represent remains.
A length of zero could be either a particularly compact zero or, horribly, an indication of absence.

This seems, to me, to be roughly the best integer bit representation that avoids arbitrary grouping.
The cost for an integer of any length is that length, plus double that incremented length's base two
logarithm's ceiling; however, this algorithm doesn't work for the integer zero, with a length three.
I've found that taking the logarithm of the logarithm results in savings too small to be worthwhile.

I've given the matter of a zero length more thought lately, and think it should be useful after all.
There are two good ways to avoid zero in a system: Increment the number, or have zero represent that
number following what would otherwise be the maximum for the given digits.  I'm inclined towards the
second option, as it only needs one digit pattern to be interpreted differently.  That solution then
is using a zero length to mean the next power of two, given the available bits; so, a length of zero
expressed with one bit would mean two, expressed with two bits would mean four, and so on.  The only
unease with this is the existence of multiple representations for some numbers, but that's preferred
over invalid representations, I suppose.  This scheme breaks even for small power-of-two bit lengths
for which the scheme lacking the special zero representation is larger, staying smaller after seven.

The ideal network may not be binary, but trinary.  Representations for those most base types of data
would be needed, but afterwards it becomes mostly irrelevant for any such high-level system.  If one
extrapolates from the most pure binary representation, and considers the controlling bits therein to
represent a length instead of mere presence, then those analogous trits can represent either a final
trit, two final trits, or two trits followed by yet more, for representing the base three logarithm.

While arbitrary in the binary case, it's probably best for the zero state to signal continuance when
using another base, as the terminal cases begin to outnumber that lone other case, and this also has
the numbers nicely read out the count of terminal digits in all bases, including in the binary case.

In a larger system with more considerations, these decisions may change, but approach the right way.