Next: Numeric Types Up: Values, Types, and Constants Previous: Overview Contents Index
Subsections

- Boolean Constants
- Logical Operators

#
Booleans

The `bool` type reflects a value with one of two possible meanings: true or false.

##
Boolean Constants

There are two `bool` constants: `T` and `F`. They represent the values of ``true" and ``false", respectively.

##
Logical Operators

Bro supports three logical operators: `&&`, `||`, and `!` are Boolean ``and,'' ``or,'' and ``not,'' respectively. `&&` and `||` are ``short circuit'' operators, as in C: they evaluate their right-hand operand only if needed.

The `&&` operator returns `F` if its first operand evaluates to false, otherwise it evaluates its second operand and returns `T` if it evaluates to true. The `||` operator evaluates its first operand and returns `T` if the operand evaluates to true. Otherwise it evaluates its second operand, and returns `T` if it is true, `F` if false.

The unary `!` operator returns the boolean negation of its argument. So, `! T` yields `F`, and `! F` yields `T`.

The logical operators are left-associative. The `!` operator has very high precedence, the same as unary `+` and `-`; see § 3.3.3 and § 8.11. The `||` operator has precedence just below `&&`, which in turn is just below that of the comparison operators (see § ).

Next: Numeric Types Up: Values, Types, and Constants Previous: Overview Contents Index