The LOGICAL_AND function performs a logical AND operation on its arguments. It returns True (1) if both of its arguments are non-zero (non-NULL for strings and heap variables), or False (0) otherwise.

The LOGICAL_AND function is similar to the AND operator, except that it performs a logical “and” rather than a bitwise “and” on its arguments.

Note: LOGICAL_AND always returns either 0 or 1, unlike the AND operator, which performs a bitwise AND operation on integers, and returns one of the two arguments for other types.

Unlike the && operator, LOGICAL_AND accepts multi-element arrays as its arguments. In addition, where the && operator short-circuits if it can determine the result by evaluating only the first argument, all arguments to a function are always evaluated.


At the IDL command line, enter:


IDL Prints:

1   0   0   0


Result = LOGICAL_AND(Arg1, Arg2)

Return Value

Integer zero (false) or one (true) if both arguments are scalars, or an array of zeroes and ones if either argument is an array.


Arg1, Arg2

The expressions on which the logical AND operation is to be carried out. The arguments can be scalars or arrays of any type other than structure.


Thread Pool Keywords

This routine is written to make use of IDL’s thread pool, which can increase execution speed on systems with multiple CPUs. The values stored in the !CPU system variable control whether IDL uses the thread pool for a given computation. In addition, you can use the thread pool keywords TPOOL_MAX_ELTS, TPOOL_MIN_ELTS, and TPOOL_NOTHREAD to override the defaults established by !CPU for a single invocation of this routine. See Appendix D, “Thread Pool Keywords” for details.

Version History



See Also