music

# ternary programming and operations

## summary

This optional chapter looks at ternary (three-state) programming, logic, and operations.

## free computer programming text book project

If you like the idea of this project,

# ternary programming and operations

This optional chapter looks at ternary (three-state) programming, logic, and operations.

### n-state logic

Almost all modern computer hardware and software is built with binary logic, simple switching machines.

In the early days of computers, there were both binary (two-state) and decimal (10-state) computers. Modern computers that have decimal hardware actually store and work with the decimal information in an underlying binary format, called Binary Coded Decimal, or BCD.

Some of the earliest computers used ternary (three-state) logic. In 1940 a team of mathematicians at Cambridge University, that included Alan Turing and Konrad Zuse, built a ternary logic computer called Trinity.

There are modern companies that build various n-state logic circuits and machines.

### ternary logic

Base three has been proposed for computers on the argument that three state logic is almost as easy to build as two state logic and that the storage of numbers (and therefore, countable items) in base three is more efficient than binary base two.

The ternary number system uses the digits 0, 1, and 2. The balanced ternary system uses the digits -1, 0, and +1.

A single digit in either ternary number system is called a trit. A ternary tryte of either six trits (as ion the Setun computer) or nine trits (theoritcal) is the computer equivalent of a binary byte.

A ternary string is a string that contains only 0s, 1s, and 2s.

Every integer can be expressed as a balanced ternary expansion of the form:

ek3k + ek-13k-1 + … + e13 + e0

The experimental Russian Setun computer, built at Moscow State University in 1958, used balanced ternary notation. Fifty Setun computers (named for the Setun River, which ends near moscow) were built between 1958 and 1965. The Forth-like programming language DSSP (Dialog System for Structured Programming) was created by computer science students at Moscow State university for the Setun computer.

“perhaps the symmetric properties and simple arithmetic of this number system will prove to be quite important some day—when the “flip-flop” is replaced by the “flip-flap-flop”.”—Fundamental Algorithms; The Art of Computer Programming; Vol. 1; by Donald Knuth

# free music player coding example

Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

View music player in action: www.musicinpublic.com/.

Create your own copy from the original source code/ (presented for learning programming).

## view text bookHTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

 previous page next page
 Tweets by @osdata

## free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

Some or all of the material on this web page appears in the

This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

†UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

Names and logos of various OSs are trademarks of their respective owners.