Home >Common Problem >false is 1 or 0
false is 0, false is a Boolean value. The only values of Boolean variables are false and true, 0 is false, and non-0 is true; Boolean variables can be used in logical expressions, that is, " Logical operations such as "OR", "AND" and "Not" and relational operations such as greater than less than.
#The operating environment of this article: Windows 7 system, Dell G3 computer.
false is 0. False is a Boolean value. The only values of Boolean variables are false and true, 0 is false, and non-0 is true. (For example -1 and 1 are both true).
Boolean variables can be used in logical expressions, that is, logical operations such as "or", "and" and "not" and relational operations such as greater than or less. The result of the logical expression operation is true or false. .
Boolean operation results are often used in conditional statements. The following is an example of Java syntax:
bool a=1; bool b=0; if (a && b) { System.out.println("1");// 只有a和b都为true时(即非0值),执行此处 }else if(b){ System.out.println("2");//只有b为true时(即非0值),执行此处 }else{ System.out.println("3");// 当前面条件都不满足时执行此处 }
So the output result is: 3
For more related knowledge, please visit PHP Chinese website!
The above is the detailed content of false is 1 or 0. For more information, please follow other related articles on the PHP Chinese website!