3 ms·
A while back I put together the base of an emulator for a fictional balanced ternary computer. I chose a completely different binary encoding method where each
by AnIdiotOnTheNet 6y ago
A while back I put together the base of an emulator for a fictional balanced ternary computer. I chose a completely different binary encoding method where each ternary value had its negative and positive trits stored separately. This undoubtedly made it slower to emulate arithmetic since my sum implementation has a while loop to deal with carries while the implementation in the article uses a variation of packed BCD math. Good to note if I ever go back to this.
I used a sort of balanced heptavintimal representation which differs significantly too. Where positive 3-trit values were represented as expect (0-D) and negative values were represented by the lowercase equivalent of the positive for letters and the symbol above the positive number key on a standard US keyboard. So for instance the number "--00-+-++" would be "c@%".
I chose a 9-trit "tryte". Each group of three trits was a called a "tone". Why "tone"? Because in the elaborate back story of the computer's creation one of its primary functions was playing simple music compositions. 3 trits yields 27 values or silence (0) and one octave each above and below including sharps and flats. A grouping of 3 such "tones" is a "tritone" or "tryte" (the spelling with 'y' helps disambiguate from 'trit' when reading).
The backstory for this thing was actually significantly more elaborate and complete than the emulator ever was. I did work out how to do parity-block style error recovery with ternary though.