Is there a name for the "boolean of 3 states"?

3

But how so a "boolean of 3 states"?

Generally used in comparison between dates, where possible results are -1 , 0 , 1 .

I was in a similar situation and I had this doubt when I wanted to ask my colleague about a possible Enum representation in Java.

    
asked by anonymous 28.08.2018 / 15:12

1 answer

4

A boolean of 3 states is what has the false, the true and the undefined. So in Java there is a natural that is Boolean , not to be confused with boolean ( What is the difference between Boolean and boolean? / a>). The first one accepts null , so there is a third state.

In C # you can use bool? . It has language that only has boolean of 3 states, and many people do not even realize it.

In languages you do not have, you would need to create a convention or even an enumeration if there is one in the language, something like this:

enum tribool { false, true, maybe = -1 }

Some people say that this should not be used, and if there are 3 states then it is not a Boolean, it is something else. In fact this date thing seems to me to be something else. Something like this:

enum compara { igual, depois, antes = -1 }
  

Is there a name for the "3-stage boolean"?

Apparently it is called trivalent or ternary logic (after all, boolean is binary), second to Wikipedia . Other terms may be used as seen in the comments. There does not seem to be a universal name. And since its use is not so encouraged, it may be better this way.

As far as I understand, no one has been credited with the "invention" and no one has been honored. The binary might not call Boolean if you did not give George Boole so much credit.

    
28.08.2018 / 16:11