Skip to main content

Questions tagged [logical-operator]

5votes
5answers
951views

Is it bad practice to use nullptr in ternary operation?

I've set up a ternary operator in place of a pile of if-else's, the final expression being nullptr in order to finish the loop, like so: int menuSelect; std::string operation=""; (...
Hench's user avatar
3votes
5answers
726views

What is the best way to make an if statement condition itself conditional?

Apologies if this is answered elsewhere here but this specific question is somewhat hard to search for as you might see. I'm writing a script currently that essentially has a simple if-then within a ...
Rushkie's user avatar
6votes
5answers
7kviews

Why don't languages like C have NAND operators?

I know that some languages like APL have a dedicated NAND operator, but I'm thinking about languages like C, C++, Java, Rust, Go, Swift, Kotlin, even instruction sets, etc. since these are the ...
Ky -'s user avatar
  • 555
2votes
3answers
2kviews

Any reason to not use a triple not?

If logical not ! will switch a boolean value from false to true or true to false and a double not !! will cast a value from one primitive type to boolean is there any reason one can not use a logical ...
1.21 gigawatts's user avatar
2votes
4answers
534views

Conditional vs Logical Testing

I would like to get your code thought and views on using conditional vs logical testing. For example: To test the conditions of truthness of all of the following variables, their currect status is ...
Mohsen Alyafei's user avatar
58votes
8answers
19kviews

Is there a keyword or operator for "nor"?

Is there an operator equivalent of nor? For example, my favorite color is neither green nor blue. And the code would be equivalent to: // example one if (color!="green" && color!="blue") { ...
1.21 gigawatts's user avatar
62votes
3answers
11kviews

&& and || are not logical but conditional operators?

I am a bit confused by the MSDN C# documentation which states that & and | are logical operators and that && and || are conditional operators. I keep calling &&, || and ! logical ...
John V's user avatar
  • 4,946
7votes
4answers
1kviews

Why is there both logical operators <> and !=?

The are two operators '<>' and '!=' used in programming languages with the same general meaning. '<>' can be used in PHP, SQL, and Pascal. '!=' seems to be more commonly used. What is the ...
Liam's user avatar
  • 189
-3votes
3answers
208views

Was there some language(s) in which its logical operators returning a true or false only?

I remember in the past, for some languages which I can't remember, be it Fortran, Pascal, or Scheme, a logical operator 2 || 3 will always return a boolean value. But in the modern languages: ...
nonopolarity's user avatar

close