Home >Common Problem >false is 1 or 0

false is 1 or 0

藏色散人
藏色散人Original
2021-02-07 10:27:0039791browse

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.

false is 1 or 0

#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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn