As a programmer I usually want variable names that makes sense. I now stumbled upon a variable that can take three different values, so called three-valued logic.

In this case I am trying to name a variable that can indicate:

-1: Only others companies

0: All companies

1: Only my companies

It actually exist a fourth case, no companies, which I'm not interested in. For a standard boolean naming is easy, onlyMyCompanies, isOtherCompany etc.

Out of pure academic interest, what prefix (or suffix) would you use for a three-valued logic?

  • 1
    This seems more like a programming conventions question than an English usage one. Feb 3, 2016 at 15:47
  • I'm voting to close this question as off-topic because it is about programming conventions, not English language.
    – DyingIsFun
    Feb 3, 2016 at 16:03
  • 3
    I'd say it's a tri-state variable. I've often used the three values +1, 0, -1 in theoretically "binary" configuration flags to mean set to ON, set to OFF, not (yet) explicitly set to anything (where I invariably #define'd the values as TRUE, FALSE, NOTFOUND, or later on used names like that in enum definitions). Feb 3, 2016 at 16:03
  • 1
    "Tri-state" is the old term for the concept. Way back when, there were advocates for tri-state over binary as the standard internal mode inside a computer. Never got very far, though, except in the odd memory chip where you could squeeze a hair more data on a chip that way.
    – Hot Licks
    Feb 3, 2016 at 16:21
  • If anything, this looks like four-valued logic to me, even though you are not interested in one of the values.
    – anemone
    Feb 3, 2016 at 16:37

4 Answers 4


Maybe I don't understand the question, but you seem to have already used a perfectly conventional adjective to describe a three-valued logic, namely three-valued.

This phrase is widely used by logicians to describe non-Boolean logics which have three truth values: true, false, and neither.

The Wikipedia you cite gives the following variants: trinary, trivalent, ternary, or trilean.


"Trinary" or "ternary", after the fashion of "binary" (which is more commonly the case) is the accepted technical term.


For Boolean variables, a pretty standard convention is to use "is" and "not" to specify the two options.


Once you get past the simple true/false logic, how you go may depend on the exact circumstances.

In your description of the three options, AllCompanies is a superset inclusive of isMyCompany and notMyCompany so how you chose to name it is probably different than what you might choose for an enumerated list if the value sets did not overlap. For example:


Wheras in your case you might want:


and, as you mentioned, recognizing the possible future inclusion of


The best rule to follow in variable naming in coding? Don't be lazy: take the time to make it descriptive, even if it does wind up with a longer name.


You can't make statements like

if isCompany(x) {...} else { ... }

because you'll have multiple cases. So maybe you'd use a switch.

switch companyState(x)

1: {...}

2: {...}

3: {...}

So I think you simply want state or something more domain specific. I don't think there's a general pattern because, well, there isn't a general pattern.

This isn't inherently 3-valued, it's n-valued. But then again Booleans aren't really two-valued--they can be null/undefined/whatever, depending on your language--which is why you get "truthiness" in things like javascript, where 'false' can be false, 0, [], etc. So isCompany(x) may actually be handled with something like:

y = isCompany(x) if( y==null ) { ... } else if( y ) {...} else {...}

The pattern used in isThing() is wonderful, but sometimes it even falls apart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.