weblog

list of entries

[all entries]

how to program in unary

quandaries with copyleft

some of my favorite sites

quantification of bitstring randomess

the parse interpreted algorithm language

guestbook

how to program in unary

20200614

It is possible to write any computer program in a unary language. This is a language whose character set is of size 1.

Instead of a binary system (e.g., digits 0 and 1), a unary system has only a single ut, or unary digit (binary: bit; unary: ut). I have decided here to use the 0 character. Instead of a traditional, positional numeral system of radix n, where n is a positive integer, it is necessary to define a new system, where zeroes can be placed together in order to present a number. This is because n to the 0th power consistently equals 1.

The new system is based only on length, where the length n corresponds to the number it represents. For example, the unary '000' equals '3' in base-10; an empty utstring would thus equal zero.

In order to translate a computer program (or indeed any string of ASCII characters) into a unary representation, the string is first converted into its nondelimited binary representation and optionally converted into decimal. This number represents the number of uts in its unary expression. Take, for example, the following 22-byte C one-liner.

void main(){return 0;}

This is converted to nondelimited binary.

01110110011011110110100101100100001000000110110101100001011010010110111000101000001010010111101101110010011001010111010001110101011100100110111000100000001100000011101101111101

The unary representation is thus 44311869819165915343581597566035780306842747617164157 uts in length, representing an untenable file size.