Skip to main content

Questions tagged [logical-operator]

5 votes
5 answers
1k views

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
  • 61
3 votes
5 answers
760 views

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
  • 49
6 votes
5 answers
7k views

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
  • 565
2 votes
3 answers
2k views

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
2 votes
4 answers
584 views

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
58 votes
8 answers
20k views

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
62 votes
3 answers
11k views

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
7 votes
4 answers
1k views

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
-3 votes
3 answers
231 views

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
  • 1,837