IDL

LOGICAL_AND

LOGICAL_AND

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.

Example


At the IDL command line, enter:

PRINT, LOGICAL_AND(2,4), LOGICAL_AND(2,0), LOGICAL_AND(0,4), $
   LOGICAL_AND(0,0)

IDL Prints:

1   0   0   0

Syntax


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.

Arguments


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.

Keywords


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


6.0

Introduced

See Also


LOGICAL_OR, LOGICAL_TRUE


This information is not subject to the controls of the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR). However, it may be restricted from transfer to various embargoed countries under U.S. laws and regulations.
© 2017 Exelis Visual Information Solutions, Inc., a subsidiary of Harris Corporation