Can you set boolean to 3?

This is getting ridiculous! OP - post the skech you are working with. Without knowing what you are doing, we cannot come up with the best solution for you!

(manor_royal: of course you are correct. two booleans, 'logic'd together, will hold 'false', 'true' and '3' perfectly! But is this what luka' is doing? Perhaps two independent tests are in order. Or a switch statement? I mean, we just don't know ...)

The original poster never said he was doing anything, or had any "problem", or needed any "solution." They just had a question; for all we know, it was just a theory question...

ChrisTenone:
This is getting ridiculous!

Not on my shift it isn't!

:wink:

westfw:
The original poster never said he was doing anything, or had any "problem", or needed any "solution." They just had a question; for all we know, it was just a theory question...

That's right! He may as well have asked:

Does 2+2 = 5?

(Beginner's question, obviously).

Again, sometimes you might want to have a nominally boolean variable hold other state information, i.e., usually want is a straight true/false but you might also want a condition that means that the data is valid, or stale or whatever.

As has been stated, a simple byte flag might work in this case with various bits representing the state info + the boolean value. An enum might also work.

But only the OP knows.

sometimes you might want to have a nominally boolean variable hold other state information,

In which case it won't be a boolean variable, particularly as the program will need to test for more than 2 states.

A good analogy is the C use of an int for a return from what would normally be a function that returns a char. It can then use "out of band" values such as -1 as a special flag.

This kind of thing is impossible with a true boolean, which is probably what led to the OP.

What a year this is going to be. :slight_smile:

Happy New Year everyone.

LarryD:
What a year this is going to be. :slight_smile:

Happy New Year everyone.

So if the boolean is 3, what year is it?

LOL

Perhaps the most helpful think would be for the OP to look at enumerated types - enums.

enum Truthvalue {
 yes, no, maybe
};

Perhaps the most helpful thing would be for the OP to tell us what problem he is trying to solve.