"be consistent" PerlMonks

Re: To Trinary or not to Ternary

 on Dec 05, 2003 at 17:49 UTC ( #312575=note: print w/replies, xml ) Need Help??

in reply to To Trinary or not to Ternary

trinary

Trinary logic is three-level digital logic, with states represented by the numbers -1, 0, and 1. Alternatively, the three states can be represented by the numbers 0, 1, and 2. The smallest number corresponds to logical falsity, the highest number to logical truth, and the middle value to logical neutrality (neither truth nor falsity). Trinary logic is not often used. Binary logic, in which there are only two states represented by 0 and 1, is the most common in computer science and electronics.

Replies are listed 'Best First'.
Re: Re: To Trinary or not to Ternary
by eric256 (Parson) on Dec 05, 2003 at 18:24 UTC

What kind of programming structure would support trinary logic?

```if (<<expr>>) {
# true
}
else
{
# false
}
otherwise
{
# nuetral??
}

Sounds like fun to me :-)

___________
Eric Hodges

A friend and myself sat down and played with trying to create a trinary based system (hardware and software). On the hardware level it was nice, as it seemed to simplify a few things.

We never did get to an actual OS implementation. I fought with the if/else structure, and still do. The simple if/else is a binary concept, and it was wrong to try and kludge it into a trinary system. We had to figure out a control structure that did the same thing, yet has 3 possible states. I just couldn't quite seem to get "out of the box" and figure out the right concept to implement. Consequently the project has been collecting dust for about a year now.

The farthest I ever got was something along the lines of almost a multiple test structure, but its really just a renamed if/else, with a builtin elsif. Pseudocode below

```   true( test_var for truth_value ) {
} false ( test_var for not other_values ) {
} neither {
# something else
}

Maybe some other monks have insight into how to really leverage this at the software level, but at this point I don't. Maybe if I had a CS degree and knew more of the fundamentals of computing I might have gotten further along. The hardware side though was really impressive. Play with the numbers. Take the possible values for a single byte, and instead of it being base 2 take it to base 3.

use perl;

For ideas you might try researching SETUN, the ternary computer the Soviets built in the 1950's.
Check out the <=> and cmp operators... :-)

Those are just functions that return -1,0 or 1. Thats easy enough. I'm talking about control statements that can respond to suck input. if,unless,while...etc all respond to only a true and false and have two actions accordingling (continue looping, execute statment, etc). What I'm wondering is what does a trinary language look like in control statments, and what use is it realy? Of course I never saw the use of LISP so perhaps I'm too short sighted :-)

___________
Eric Hodges

Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2022-08-08 22:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?

No recent polls found

Notices?