Home > Common Problem > body text

false is 1 or 0

藏色散人
Release: 2021-02-07 10:27:00
Original
39776 people have browsed it

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");// 当前面条件都不满足时执行此处
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template