askvity

Is "yes" a valid Boolean?

Published in Boolean Logic 2 mins read

No, "yes" is not a valid Boolean value in programming.

While a Boolean concept represents the answer to a yes/no question, Booleans in computer science have specific values. A Boolean data type can only hold one of two possible values: true or false.

Here's why "yes" isn't a Boolean and how it relates:

  • Boolean Definition: A Boolean is a fundamental data type in programming that represents logical values. It's used to represent truth values, and has only two possible values.

  • Valid Boolean Values: The only valid Boolean values are true and false. These are often keywords in programming languages.

  • "Yes" as Representation: The word "yes" represents the true Boolean value in a human-readable format. Similarly, "no" represents false. However, these are not the values themselves.

  • Example: Imagine a condition in a program: isRaining = true; Here, isRaining is a Boolean variable, and it's assigned the true Boolean value, not the string "yes".

Concept Value
Boolean True true
Boolean False false
Human Readable True yes
Human Readable False no

Therefore, while "yes" can indicate a true Boolean condition, the actual Boolean value used in programming is true. Using "yes" directly as a Boolean will likely result in a syntax error or unexpected behavior, depending on the programming language.

Related Articles