# 逻辑函数

This category contains the Logical functions.

### Handling non-logical arguments in logical functions

• Zero (0) is equivalent to FALSE and all other numbers are equivalent to TRUE.

• Empty cells and text in cells are ignored.

• A #VALUE error is raised if all arguments are ignored.

• A #VALUE error is raised if one argument is direct text (not text in a cell).

• Errors as argument lead to an error.

## AND

### 语法

AND(LogicalValue1; LogicalValue2 ...LogicalValue30)

LogicalValue1; LogicalValue2 ...LogicalValue30 are conditions to be checked. All conditions can be either TRUE or FALSE. If a range is entered as a parameter, the function uses all values of the range. The result is TRUE if the logical value in all cells within the cell range is TRUE.

### 示例

=AND(12<13;14>12;7<6) 返回 FALSE.

=AND (FALSE;TRUE) 返回 FALSE.

## FALSE

FALSE()

### 示例

=FALSE() 返回 FALSE

=NOT(FALSE()) 返回 TRUE

## IF

### 语法

IF(Test; ThenValue; OtherwiseValue)

Test 是 TRUE 或 FALSE 的任意值或表达式。

ThenValue （可选择的）是逻辑测试结果为 TRUE 时返回的值。

OtherwiseValue（可选择的）是逻辑测试结果为 FALSE 时返回的值。

In the LibreOffice Calc functions, parameters marked as "optional" can be left out only when no parameter follows. For example, in a function with four parameters, where the last two parameters are marked as "optional", you can leave out parameter 4 or parameters 3 and 4, but you cannot leave out parameter 3 alone.

### 示例

=IF(A1>5;100;"太小") 如果单元格 A1 的值大于 5，则在当前单元格中输入值 100；否则以文本格式输入“太小”（无引号）。

## NOT

### 语法

NOT(LogicalValue)

LogicalValue 是要补余的数值。

### 示例

=NOT(A)。如果 A=TRUE，则 NOT(A) 为 FALSE。

## OR

### 语法

OR(LogicalValue1; LogicalValue2 ...LogicalValue30)

LogicalValue1; LogicalValue2 ...LogicalValue30 are conditions to be checked. All conditions can be either TRUE or FALSE. If a range is entered as a parameter, the function uses all values of the range.

### 示例

=OR(12<11;13>22;45=45) 返回 TRUE.

=OR(FALSE;TRUE) 返回 TRUE.

## TRUE

TRUE()

### 示例

=AND(A;B) 返回 FALSE

=OR(A;B) 返回 TRUE

=NOT(AND(A;B)) 返回 TRUE

## XOR

### 语法

XOR(逻辑值1; 逻辑值2 ...逻辑值30)

### 示例

=XOR(TRUE;TRUE) 返回 FALSE

=XOR(TRUE;TRUE;TRUE) 返回 TRUE

=XOR(FALSE;TRUE) 返回 TRUE