User Tools

Site Tools


and

Table of Contents

and

and is a logical-conjunction operator

syntax

result = numeric-expression1 and numeric-expression2

See also or, nor, not, xor, eqv, imp

details

the and logical conjunction operator compares two expressions and returns the boolean value true if and only if both expressions are true (non-zero). In any other case, the result is false. See the table below.

expression 1    expression 2    result
    true            true         true
    true            false        false
    false           true         false
    false           false        false

Logical operators are not to be confused with Bitwise Operators.

example

In this example a conjunction comparison is performed on two integer variables using an if-statement.

' SharpBASIC and programming example
' ----------------------------------
incl "lib/sys.sbi";

dim a, b: int = 1;

main do
  if a and b do
    print(true);
  else do
    print(false);
  end
end
Output:

-1

and.txt · Last modified: 2023/06/26 10:39 by admin