逻辑函数

This category contains the Logical functions.

Handling non-logical arguments in logical functions

要访问此命令...

插入 - 函数 - 类别 逻辑


AND

如果所有参数都为 TRUE,则返回 TRUE。如果某个参数为 FALSE,则该函数返回 FALSE。

参数应该是能返回逻辑值的逻辑表达式 (TRUE, 1<5, 2+3=7, B8<10),或包含逻辑值的矩阵 (A1:C3)。

语法

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.

示例

检查 12<13; 14>12 和 7<6 的逻辑值:

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

=AND (FALSE;TRUE) 返回 FALSE.

FALSE

返回逻辑值 FALSE。函数 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

至少有一个参数为 TRUE 时,函数返回 TRUE。如果所有参数的逻辑值都为 FALSE,该函数返回 FALSE。

参数应该是能返回逻辑值的逻辑表达式 (TRUE, 1<5, 2+3=7, B8<10),或包含逻辑值的矩阵 (A1:C3)。

语法

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.

示例

检查 12<11; 13>22 以及 45=45 的逻辑值。

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

=OR(FALSE;TRUE) 返回 TRUE.

TRUE

逻辑值设置为 TRUE。函数 TRUE() 不需要任何参数,并始终返回逻辑值 TRUE。

语法

TRUE()

示例

当 A=TRUE 且 B=FALSE 时,出现下列结果:

=AND(A;B) 返回 FALSE

=OR(A;B) 返回 TRUE

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

XOR

若值为TRUE的参数的个数为奇数时,则返回TRUE。

参数可以是返回逻辑值的表达式 (TRUE, 1<5, 2+3=7, B8<10),或者是包含逻辑值的数组 (A1:C3) .

语法

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

示例

=XOR(TRUE;TRUE) 返回 FALSE

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

=XOR(FALSE;TRUE) 返回 TRUE