Unveil

Code

Ways of writing that hide nothing by design — bases, bits, binary formats, floats, Unicode, Morse, QR codes, Roman numerals, timestamps, coordinates, check digits — read and written both ways.

Number Bases

Writes a whole number in other positional systems: any base from 2 to 36; the negative bases, which need no minus sign; balanced ternary, with the digits −1, 0 and 1; the factorial base; and Zeckendorf’s sums of Fibonacci numbers. One writing is drawn place by place, each digit times its place’s weight. Also the number as LEB128 and as fixed-width bytes.

History, how it works, how it was checked, limits

History

A positional system writes a number as digits, each weighed by its place. The weight need not be a power of ten, nor of a positive number: with base −2 the odd places weigh below zero, and every whole number, negative ones too, is written without a sign. Balanced ternary takes the digits −1, 0 and 1 to the same end. The factorial base weighs its places 1!, 2!, 3! and so on. Zeckendorf’s theorem says every whole number from 1 up is a sum of Fibonacci numbers no two of them neighbours, in one way only. LEB128 is how the DWARF debugging format writes a number in as few bytes as it needs.

How it works

A whole number is typed in one system and written in all of them: binary, octal, decimal, hexadecimal, a chosen base from 2 to 36 or from −2 to −36, negabinary, negadecimal, balanced ternary (+, 0 and −), the factorial base and Zeckendorf’s representation. Digits past 9 are the letters A to Z; in the factorial base a digit past 9 is written in decimal with colons between the digits. One writing is drawn place by place: each row a digit, the weight of its place, their product, and a bar as long as the product’s share of the largest; a product below zero is drawn in outline. Under it the number stands as bytes: LEB128, unsigned and signed, and a fixed width of 16, 32 or 64 bits in either byte order.

How it was checked

The tests write the first 1,500 whole numbers in bases 2 to 9, −2 and −10, the factorial base and Zeckendorf’s representation, and the digits of balanced ternary, and hold each to the terms of its sequence in the On-Line Encyclopedia of Integer Sequences, 19,500 terms in all. On 4,000 seeded numbers, some of forty digits, every writing’s places sum to the number and the writing reads back to it. LEB128 gives the thirteen examples of the DWARF standard’s Tables 7.7 and 7.8.

The tests hold 19 checks of this tool; 6 rest on outside material:

  • A standard’s own vectors DWARF 5, Table 7.7: 2, 127, 128, 129 and 12857 as unsigned LEB128 (12857 is 57 + 0x80 then 100)
  • A standard’s own vectors DWARF 5, Table 7.8: 2, −2, 127, −127, 128, −128, 129 and −129 as signed LEB128
  • Another’s computation OEIS A007088 to A007095: the first 1,500 whole numbers in bases 2 to 9, every term
  • Another’s computation OEIS A039724 (base −2) and A039723 (base −10): the first 1,500 numbers written without a sign, every term
  • Another’s computation OEIS A007623 (the factorial base) and A014417 (Zeckendorf’s representation): the first 1,500 numbers, every term
  • Another’s computation OEIS A059095: the digits −1, 0 and 1 of balanced ternary for 1, 2, 3 … one after another, the first 1,500 of them

Every tool’s checks

Limits

Whole numbers only: no fractions, and at most 400 digits. The factorial base and Zeckendorf’s representation write numbers from 0 up. Balanced ternary’s +, 0 and − are a plain notation. Knuth’s account of these systems is cited and was not read; the rules rest on their definitions and on agreement with the OEIS. What a number is, is Number Properties’ to say.